Asked By
grahamamie
20 points
N/A
Posted on - 08/29/2011
Hi all,
Please provide me a solution to insert the text which has apostrophe. Example : aaab's.
Messages:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'GH'.
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ')
'.
Thanks in advance.
Grahamamie
Not able to insert the text in SQL query which has apostrophe
Yes, that is a problem many users of SQL face. Using an apostrophe in the code, requires a small and easy task. It needs to be done just as in the HTML code, which you code. You should replace each apostrophe with two, so that you can insert an apostrophe into the code.
For example if you want to insert an apostrophe into the code try the following:
Insert into foo (name) values ('duncan o''toole")
Cheers.
Answered By
deshow06
0 points
N/A
#93199
Not able to insert the text in SQL query which has apostrophe
-
In SQL strings are enclosed within single quotes '………' . So if a string has an apostrophe within it, then it has to result in an error.
-
The solutions is to put two apostrophes in the string, as show below:
Or Using most of the programming language by replacing the single quotes with a double quote by use of replace function. For example in vb.net as shown below:
Not able to insert the text in SQL query which has apostrophe
Thank you both for the help.