How Can I Use Single Quote Inside Sql Command?
Possible Duplicate: How do I escape a single quote in sqlserver? I got a script below that drop everything on the database from this link. It does error when I execute on this l
Solution 1:
if you want to use single quote inside a prepared statement, escape it with another single quote, example,
SET @statement = 'world''s view';
SET @statement2 = 'world''s view';
from your example above
SET@statement='
IF(@type = ''F'') or (@type = ''C'') or
(@type = ''D'') or (@type=''F'') or
(@type=''K'')'-- the strings are all red.
Solution 2:
Single quote is used to represent a string literal in SQL. If you need to explicitly insert a single quote , you should use double single quotes ('')
Solution 3:
It should be like this:
SET@statement='IF(@type = ''F'') or (@type = ''C'') or (@type = ''D'') or (@type=''F'') or (@type=''K'')'
Raj
Post a Comment for "How Can I Use Single Quote Inside Sql Command?"