question

omprakashsahlive2222 avatar image
omprakashsahlive2222 asked

replace between spacial charecter

i want to repalce word like declare @strval varchar(160) set @strval='ok all the best#Welcome#kkkkkkkkkkkkkkkkk' declare @OUTPUT varchar(20),@ss varchar(30)=''; declare @idx int; DECLARE @CHARIDX INT; SET @CHARIDX= CHARINDEX('#',@strval); if(@CHARIDX !=0) begin SET @ss = substring(SUBSTRING(@strval,@CHARIDX+1 ,LEN(@strval)),0,LEN(SUBSTRING(@strval,@CHARIDX+1 ,LEN(@strval)))); end select @ss only welcome will be display because it is inside %welcome% and than it will be replace into ******
sql-server-2008replace
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
tkrevathi avatar image
tkrevathi answered
declare @strval varchar(160) set @strval='ok all the best#Welcome#kkkkkkkkkkkkkkkkk' declare @OUTPUT varchar(20), @ss varchar(30)=''; declare @idx int; DECLARE @CHARIDX INT; SET @CHARIDX= CHARINDEX('#',@strval); if(@CHARIDX !=0) begin SET @ss = substring(SUBSTRING(@strval,@CHARIDX+1 ,LEN(@strval)),0,CHARINDEX('#',SUBSTRING(@strval,@CHARIDX+1 ,LEN(@strval)))) ; end select @ss
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.