Wednesday, December 12, 2012

Replace Text in Sql Server


We can use REPLACE function in Sql Server to replace specified text in a string.

declare @myString varchar(100)='My country is India'
set @myString=REPLACE(@myString,'India','Sri lanka')
select @myString as 'Final_Text'

REPLACE() function has three parameters specified.
Original string, text to be replaced, text to be replaced with

Out put:
My country is Sri lanka

No comments:
Write comments
Recommended Posts × +