SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO ALTER PROCEDURE Replace_tablename @strword varchar(200) ,@replaceword varchar(200) AS BEGIN declare @count int ,@ziduanname varchar(50) ,@tablename varchar(50) ,@ziduanleixing varchar(50) ,@sql Nvarchar(800) declare cur_LocationList cursor fast_forward for select a.name ,b.name,c.name from syscolumns a inner join sysobjects b on a.id=b.id and b.xtype='u' and lower(a.name) not in('desc','order','top','left','bottom','right') inner join systypes c on a.xtype=c.xusertype and c.name in('varchar','char','nvarchar','nchar') open cur_LocationList fetch next from cur_LocationList into @ziduanname,@tablename,@ziduanleixing while @@fetch_status = 0 begin set @count=0 set @sql='update ['+@tablename+'] set [' + @ziduanname +']=replace(['+ @ziduanname +'],''' + @strword +''','''+@replaceword +''') where ['+@ziduanname+'] like ''%'+@strword+'%''' print '±í£º'+@tablename+' ÁУº' + @ziduanname exec sp_executeSql @sql fetch next from cur_LocationList into @ziduanname,@tablename,@ziduanleixing end close cur_LocationList deallocate cur_LocationList END GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO