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

Replacing apostrophes in an SQL statement

Status
Not open for further replies.

cinbh

MIS
Apr 16, 2002
58
US
We are using SQL 2000 and with Apex
I am currently using a replace on my company name field to take out commas, ampersands etc. Problem is I need to take out aprostrophes too, but I think Apex or SQL won't recognize the double quotes as valid. So the following does not work
Replace(CompanyName,"'","''")
my replace using the following does work
Replace(CompanyName,',',' ') Giving me a space where I had a comma in the name. How could I remove an apostrophe if it will not recognize the doublequote? I'm just cleaning up enduser output and NOT changing the table data. The table data is fine with the apostrophe it's just specialized output.
Thanks
Cindy
 
Hi double tick inside of the string will act as one tick. also I replace the tick with and "accute Accent" alt-0180

declare @string varchar(50)
set @string = 'tal''s pizza'

Print 'original:' + @string
set @string =replace(@string,'''','´')

Print 'replaced:' + @string

hth

Tal McMahon
 
Actually, I should clarify that we use the single quote as the apostrophe.
 
THANKS to both of you. The double ticking with the single quotes finally worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top