Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String parameters with single or double quotes

Status
Not open for further replies.

jwaldner

Programmer
Jan 21, 2011
77
US
wondering how to deal with String parameters that may have single or double quotes in them. I think they are breaking my report. I am using a command to run a query.
 
To enter a quote in a string, put two of them there...

"""" will appear as a string as a single
 
I do not have control over what the parameter data contains, the user enters a string [to search for ] as a parameter. if that string has a ' or " the report breaks. so i need a way to scrub the data before the query is run in the command.

I have tried this, but it did not work:

SET @SUBJECT = Replace(@SUBJECT, '''', '''''')

...rest of query...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top