Find and Replace a substring in sql in a column of sql table
Find and Replace a particular substring in a particular row of sql server
declare @SearchStr as nvarchar(50)
declare @SearchStr2 as nvarchar(50)
declare @ReplaceStr as nvarchar(50)
declare @SQL nvarchar(4000)
set @SearchStr='&'
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
set @ReplaceStr='and'
SET @SQL= 'UPDATE tbl_us_h_bkp SET Name = REPLACE(Name, '
+ QUOTENAME(@SearchStr, '''') + ', ' + QUOTENAME(@ReplaceStr, '''') +
') WHERE name LIKE ' + @SearchStr2
EXEC (@SQL)
Comments
Post a Comment