基本信息
源码名称:MSSQL遍历所有表 删除指定的字符(可用于删除被黑的脚本)
源码大小:1.46KB
文件格式:.sql
开发语言:SQL
更新时间:2014-06-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
declare @delStr varchar(8000) set @delStr='</title><style>.a84c{position:absolute;clip:rect(476px,auto,auto,476px);}</style><div class=a84c' set nocount on declare @tableName nvarchar(100),@columnName nvarchar(100),@tbID int,@iRow int,@iResult int declare @sql nvarchar(500) set @iResult=0 declare cur cursor for select name,id from sysobjects where xtype='U' open cur fetch next from cur into @tableName,@tbID while @@fetch_status=0 begin declare cur1 cursor for --xtype in (231,167,239,175,99,35) 为char,varchar,nchar,nvarchar,ntext,text类型 select name from syscolumns where xtype in (231,167,239,175,99,35) and id=@tbID open cur1 fetch next from cur1 into @columnName while @@fetch_status=0 begin set @sql='update [' @tableName '] set [' @columnName ']= replace(cast([' @columnName '] as varchar(8000)),''' @delStr ''','''') where [' @columnName '] like ''%' @delStr '%''' --update tablename set fieldA=replace(cast(fieldA as varchar(8000)) ,'aa','bb')这样的语句。 exec sp_executesql @sql set @iRow=@@rowcount set @iResult=@iResult @iRow if @iRow>0 begin print '表:' @tableName ' ,列:' @columnName '被更新' convert(varchar(10),@iRow) '条记录;' end fetch next from cur1 into @columnName end close cur1 deallocate cur1 fetch next from cur into @tableName,@tbID end print '数据库共有' convert(varchar(10),@iResult) '条记录被更新!!!' close cur deallocate cur set nocount off