Monday, September 16, 2019

sql server - TSQL Use ' in string assignment

Trying to use a single quote and assign it to a variable so I can create a dynamic report.



The problem is when I do this:



set @Statequery = (' and PostalState = ' ')  +  @PostalState  + '''


If you do this, print @Statequery, it needs it to look like this.



and postalState = 'QLD'


How do I escape the ' character in this case?



Thanks for your help in advanced,



Ryan

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...