最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

除MSSQL數(shù)據(jù)庫text字段中惡意腳本的刪方法

 更新時(shí)間:2009年07月29日 19:12:15   作者:  
刪除MSSQL數(shù)據(jù)庫text字段的替換處理示例--全表替換,看到有人提問,所以整理了一個(gè)好久以前的處理方法,以供大家參考
方法很簡(jiǎn)單:text字段不能使用Replace,所以使用patindex
復(fù)制代碼 代碼如下:

-select * from Product where P_Intro like '%<script src="http://my.stsw518.cn/a002/1.js" src="http://my.stsw518.cn/a002/1.js"></script>%'
--text字段的替換處理示例--全表替換
-- select datalength(P_Intro),* from Product
--邀月 整理
--定義替換的字符串
declare @s_str nvarchar(4000),@d_str nvarchar(4000)
select @s_str='<script src="http://my.stsw518.cn/a002/1.js" src="http://my.stsw518.cn/a002/1.js"></script>' --要替換的字符串
,@d_str='' --替換成的字符串


--因?yàn)橹荒苡胮atindex,所以對(duì)于搜索字符串做處理
set @s_str='%'+@s_str+'%'

--定義游標(biāo),循環(huán)處理數(shù)據(jù)
declare @id bigint
declare #tb cursor for select P_ID from Product where P_Intro like '%<script src="http://my.stsw518.cn/a002/1.js" src="http://my.stsw518.cn/a002/1.js"></script>%'
-- where P_ID=300727 ----where P_Intro like '%<script src="http://my.stsw518.cn/a002/1.js" src="http://my.stsw518.cn/a002/1.js"></script>%'
open #tb
fetch next from #tb into @id
while @@fetch_status=0
begin
--字符串替換處理
declare @p varbinary(16)
,@p1 int,@p2 int
,@rplen int,@step int,@len int

select @p=textptr(P_Intro)
,@rplen=len(@s_str)-2
,@step=len(@d_str)
,@p1=patindex(@s_str,P_Intro)
,@len=datalength(P_Intro)
,@p2=0
from Product
where P_id=@id

while @p1>0
begin
set @p2=@p1+@p2-1
updatetext Product.P_Intro @p @p2 @rplen @d_str
select @p2=@p2+1,@p1=patindex(@s_str,substring(P_Intro,@p2+1,@len))
from Product where P_ID=@id
end
fetch next from #tb into @id
end
close #tb
deallocate #tb

--顯示結(jié)果
---- select datalength(P_Intro),* from Product

相關(guān)文章

最新評(píng)論

延津县| 柏乡县| 青神县| 沁阳市| 新野县| 玉田县| 绥化市| 郯城县| 沈阳市| 龙胜| 景德镇市| 青海省| 崇阳县| 澄城县| 江山市| 西贡区| 全南县| 霍山县| 吉林市| 托里县| 集贤县| 焉耆| 搜索| 朝阳区| 阿克苏市| 双桥区| 汕尾市| 扶余县| 海原县| 肇庆市| 延边| 绥江县| 兴化市| 南通市| 丰都县| 肇州县| 本溪| 读书| 无为县| 盐源县| 昌江|