By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Problem inserting ' and ; in DB

P: 14

I am inserting a comments value i.e a field which contains comments into a DB which is provided by the user as input.

If the value for the field contains quotes (both " and ') as well as semi colon (;), the results in an error.

Please help me include these special characters into the DB.

Thanks in advance.
Apr 15 '09 #1
Share this Question
Share on Google+
7 Replies

P: 6
insert into @table1 values('03-11-2004',102252271,100061, ';Eli NewName''"')
Apr 16 '09 #2

P: 14
I don understand what you have given. Please explain me more on this issue.
Apr 16 '09 #3

P: 6
this is the way u can enter special characters in db.
for inserting ' you need to insert ''
thats it
Apr 16 '09 #4

P: 14
Yeah i found out this jus nw. I am able to insert the value but while retrieving the same from the DB i get lot of errors. Do u have any idea abt ths?
Apr 16 '09 #5

P: 6
What errs r u getting. post the errs with test data

Apr 16 '09 #6

P: 14

The value I am trying to retrieve is a'b'c. I used the replace() fn by replacing ( ' ) with ( '' ) at the time of insertion into the DB.

This is the error that i get when i try to retrieve the value from the DB. The query is as follows:
select name from Table1; (the value of name here is a'b'c)
Incorrect syntax near '='. (severity 15)

Please help me out.
Thanks in advance.
Apr 17 '09 #7

P: 6
declare @table1 table (date datetime,Agrid int,chkId int,name varchar(18) )

insert into @table1 values('03-11-2004',102252271,100061, 'a''b''c')
insert into @table1 values('03-11-2004',102252271,100842, 'Eli OldName')
insert into @table1 values('11-11-2004',102252271,100843, 'Eli OldName') ;
select * from @table1 where name ='a''b''c'

This will help u. worked for me
Apr 17 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.