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!

How to find a character in table of records and then replace it

Status
Not open for further replies.

michellerobbins56

Programmer
Jan 10, 2006
89
GB
Hi

Please can anyone tell me how to find a certain character in some records and then replace it with another. Basically I need to search my database records in a certain field and find any single quotes and replace them with ` instead. I can do this in ASP but I'm not sure how to do this in SQL (by using Query Analyser).

Thank you very much for any help and examples.
 
Code:
UPDATE MyTable SET MyField = REPLACE(MyField,'''','`')
       WHERE CHARINDEX('''',MyField) > 0


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top