Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Escaping quote character
Message
 
 
To
06/10/2014 11:06:42
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01608856
Message ID:
01608857
Views:
34
This message has been marked as a message which has helped to the initial question of the thread.
>Usually, when I generate a script, the quote character is converted like this:
>
>
>...WHERE Client.City='Michel''s city'
>
>
>That would work.
>
>I can also do this:
>
>
>...WHERE Client.City='Michel'+CHAR(39)+'s city'
>
>
>But, in cases where I need to pass the entire command as a variable, I cannot use the double quote and SQL Server complains if I use this:
>
>
>SET @SQL='...WHERE Client.City=''Michel'+CHAR(39)+'s city'''
>
>
>It does not like CHAR(39) if inserted inside a string which is also inserted inside a string.
>
>Any idea on how to resolve this?
SET @SQL='...WHERE Client.City=''Michel''''s city'''
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform