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
 General SQL Server Forums
 New to SQL Server Programming
 replace function

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2009-09-25 : 02:08:49
declare @test varchar(100)
set @test='hello ''select * from table'
set @test=replace (@test,'''''select''',' sselect ')
print @test


actual output should come as:
hello select * from table


now,the value coming as:
hello 'select * from table

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-25 : 02:16:24
declare @test varchar(100)
set @test='hello ''select * from table'
set @test=replace (@test,'''select',' select ')
print @test



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-25 : 03:21:32
Refer this to know how singlw quotes work in SQL Server
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

Madhivanan

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

- Advertisement -