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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to SELECT when field contains single quote?

Status
Not open for further replies.

jcfrasco

IS-IT--Management
Apr 27, 2001
89
US
I'm wanting to use the SQL Query Analizer, or possibly program the statement into my Delphi program, to SELECT all records that have a single quote in the string and replace it with a string without the single quote. Example of type of data in field: 48 x 125' Bubble Wrap. I can't seem to find the right combination of characters because when I try to form my SQL SELECT statment the string must be surrounded by quotes and it sees the single quote in the string as the closing quote. Please let me know how I can get around this because I would like to run an update on the table and replace all the selected records with a description that doesn't have quotes in it.

I appreciate any advice in this matter!

jcfrasco
 
I am not sure but try to use REPLACE function on the variable before passing it in your query.

Like:

varName= REPLACE(varName,"'","''")

Hope that works

VJ

 
I think this will give you want you want in the search

select blah blah blah blah where table.field like '%' + '''' + '%'

that would be 4 single quotes and not 2 double quotes.

That should look for anything that has a ' in the string.

"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001
 
Thanks for the help! I tried the recommendations and they solved my problem.

This is a great site!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top