declare @sql varchar(500)
set @sql= 'print ''一般字符'''
exec (@sql)
set @sql= 'print ''一般"字符"'''
exec (@sql)
set @sql= 'print ''一般''''字符'''''''
exec (@sql)
create proc ReplaceString
@tablename nvarchar(50),
@fieldname nvarchar(50),
@exp1 nvarchar(50),
@exp2 nvarchar(50),
@whereExp nvarchar(50),
@wherefield nvarchar(50)
as
DECLARE @Sql nvarchar(1000)
set @Sql='update '+@tablename+' set '+@fieldname+'=replace('+@fieldname+','''+@exp1+''','''+@exp2+''') where '+@wherefield+' in (select '+@wherefield+' from '+@tablename+' where '+@fieldname+' like '''+@whereExp+''')'
EXEC sp_executesql @Sql
print @Sql
go