首页 数据库 mysql教程 除MSSQL数据库text字段中恶意脚本的删方法

除MSSQL数据库text字段中恶意脚本的删方法

Jun 07, 2016 pm 05:58 PM
mssql text

删除MSSQL数据库text字段的替换处理示例--全表替换,看到有人提问,所以整理了一个好久以前的处理方法,以供大家参考

方法很简单:text字段不能使用Replace,所以使用patindex
代码如下:
-select * from Product where P_Intro like '%%'
--text字段的替换处理示例--全表替换
-- select datalength(P_Intro),* from Product
--邀月 整理
--定义替换的字符串
declare @s_str nvarchar(4000),@d_str nvarchar(4000)
select @s_str='' --要替换的字符串
,@d_str='' --替换成的字符串


--因为只能用patindex,所以对于搜索字符串做处理
set @s_str='%'+@s_str+'%'

--定义游标,循环处理数据
declare @id bigint
declare #tb cursor for select P_ID from Product where P_Intro like '%%'
-- where P_ID=300727 ----where P_Intro like '%%'
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

--显示结果
---- select datalength(P_Intro),* from Product
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章

仓库:如何复兴队友
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前 By 尊渡假赌尊渡假赌尊渡假赌

热门文章标签

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

php怎么连接mssql数据库 php怎么连接mssql数据库 Oct 23, 2023 pm 12:02 PM

php怎么连接mssql数据库

Ubuntu安装PHP并配置MSSQL连接的详细指南 Ubuntu安装PHP并配置MSSQL连接的详细指南 Feb 29, 2024 am 11:15 AM

Ubuntu安装PHP并配置MSSQL连接的详细指南

Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解 Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解 Feb 29, 2024 am 10:39 AM

Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解

Ubuntu下安装PHP并连接MSSQL数据库的完整教程 Ubuntu下安装PHP并连接MSSQL数据库的完整教程 Feb 29, 2024 am 11:18 AM

Ubuntu下安装PHP并连接MSSQL数据库的完整教程

一次mssql注入+白名单上传绕过360的示例分析 一次mssql注入+白名单上传绕过360的示例分析 May 12, 2023 pm 02:37 PM

一次mssql注入+白名单上传绕过360的示例分析

ubuntu怎么安装php mssql ubuntu怎么安装php mssql Jan 28, 2023 am 09:25 AM

ubuntu怎么安装php mssql

Winnti黑客组织MSSQL后门的示例分析 Winnti黑客组织MSSQL后门的示例分析 May 27, 2023 pm 09:04 PM

Winnti黑客组织MSSQL后门的示例分析

Linux系统Apache优化与防盗链详细教程 Linux系统Apache优化与防盗链详细教程 Feb 20, 2024 am 09:00 AM

Linux系统Apache优化与防盗链详细教程

See all articles