Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Using SQL Replace function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-12-04 : 08:18:14
Cashrolls2 writes "How do you replace a single quote character i.e: ' with empty space with a string statement. when I tried the code below, i got the following error:Line 101: Incorrect syntax near ','.

=========================================================
SET @SQL = @SQL + ' REPLACE(LTRIM(LastName),''''','''') '

I am preparing a string statement to be executed later.

Thanks"

Kristen
Test

22859 Posts

Posted - 2006-12-04 : 08:26:56
SET @SQL = @SQL + ' REPLACE(LTRIM(LastName),'''''''','''') '

Kristen
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 08:27:57
SET @SQL = @SQL + ' REPLACE(LTRIM(LastName), CHAR(39), '''''


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 09:22:13
quote:
Originally posted by Peso

SET @SQL = @SQL + ' REPLACE(LTRIM(LastName), CHAR(39), ''''')


Peter Larsson
Helsingborg, Sweden



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-12-04 : 10:21:36
quote:
Originally posted by madhivanan

SET @SQL = @SQL + ' REPLACE(LTRIM(LastName), CHAR(39), '''')'
Madhivanan





Probably needs to be SELECT rather than SET anyway ... but ...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 10:27:26
Double Correction


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -