I've the following requirement. I'm passing 'ABC DEF' as a command parame开发者_JS百科ter @MyString to a stored procedure. In the stored procedure level i need to replace the substring DEF with XYZ to get the string 'ABC XYZ'. How can i do that?
Thank you. NLV
Just use the replace function within T-SQL
declare @myOriginalString varchar(50)
set @myOriginalString = 'ABC DEF'
declare @myfindstring varchar(50)
set @myfindstring = 'DEF'
declare @myReplaceString varchar(50)
set @myReplaceString = 'XYZ'
select replace(@myOriginalString,@myFindString, @myReplaceString)
精彩评论