Home Database Mysql Tutorial 除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
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to connect php to mssql database How to connect php to mssql database Oct 23, 2023 pm 12:02 PM

Methods for php to connect to mssql database include using PHP's MSSQL extension, using PDO, etc. Detailed introduction: 1. Use PHP's MSSQL extension method to ensure that PHP has the MSSQL extension installed. You can check whether the mssql extension is enabled in the PHP configuration file (php.ini); 2. Use the PDO method to ensure that PHP has the PDO extension installed. You can check whether the pdo_sqlsrv extension is enabled in the PHP configuration file (php.ini).

Detailed guide to install PHP and configure MSSQL connection on Ubuntu Detailed guide to install PHP and configure MSSQL connection on Ubuntu Feb 29, 2024 am 11:15 AM

Ubuntu is a popular open source operating system commonly used to run servers. Installing PHP and configuring MSSQL connections on Ubuntu is one of the operations that many developers and system administrators often need to do. This article will provide readers with a detailed guide, including the steps to install PHP, set up Apache, install MSSQLServer, etc., and attach specific code examples. Step 1: Install PHP and related extensions First, we need to install PHP and related extensions to support PHP connections

Detailed steps to install PHP to support MSSQL database in Ubuntu environment Detailed steps to install PHP to support MSSQL database in Ubuntu environment Feb 29, 2024 am 10:39 AM

Detailed steps for installing PHP to support MSSQL database in Ubuntu environment. When developing web applications, you often encounter situations where you need to connect to the Microsoft SQL Server (MSSQL) database. In the Ubuntu environment, to connect PHP to the MSSQL database, you need to install relevant software and configure appropriate settings. Next, we will introduce in detail the steps to install PHP to support MSSQL database in Ubuntu environment and provide specific code.

Complete tutorial on installing PHP and connecting to MSSQL database under Ubuntu Complete tutorial on installing PHP and connecting to MSSQL database under Ubuntu Feb 29, 2024 am 11:18 AM

Installing PHP and connecting to MSSQL database under the Ubuntu operating system is one of the skills that many developers and system administrators need to master. This article will provide a detailed tutorial, including installing PHP, installing the MSSQL server driver, configuring PHP to connect to the MSSQL database, and providing corresponding code examples. Part One: Install PHP First, we need to install PHP and related extensions to be able to connect to the MSSQL database. Enter the following command in the terminal to install PHP and necessary extensions

An example analysis of mssql injection + whitelist upload to bypass 360 An example analysis of mssql injection + whitelist upload to bypass 360 May 12, 2023 pm 02:37 PM

Information collection: The site is built using vue+aspx+iis8.5. The site login box has a version number and the word siteserver exists in the URL column, so it is suspected that it was built by cms, but I have not seen the cms. Using Google search, I found that the site was built with siteserver cms, the version is the latest, and the vulnerability provided on the Internet is This cannot be used. I tried injection + weak password + verification code bypass + unauthorized and other methods in the login box to no avail. Since I have a test account, I simply log in to the site directly for testing. The picture is the login picture I found online. The red box was the version number instead of the cms prompt. Functional test: After entering the background, I briefly browsed the functions, mostly for page management.

How to install php mssql on ubuntu How to install php mssql on ubuntu Jan 28, 2023 am 09:25 AM

How to install php mssql on ubuntu: 1. Enter the terminal command window; 2. Execute "curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/ mssql-release.list"; 3. Install "pdo_sqlsrv" through the install command.

Example analysis of MSSQL backdoor from Winnti hacker group Example analysis of MSSQL backdoor from Winnti hacker group May 27, 2023 pm 09:04 PM

For some time, ESET researchers have been tracking the activities of Winnti, a group that has been active since 2012 and has targeted the video game and software industry supply chains. Recently, a previously undocumented backdoor was discovered that targets Microsoft SQL (MSSQL). This backdoor bears many similarities to the PortReuse backdoor, another tool used by WinntiGroup and first documented in October 2019. This year, a new backdoor sample, skip-2.0, was detected. The author is a member of the winnti organization. This backdoor targets MSSQL Server 11 and 12 and allows attackers to use magi

Detailed tutorial on Apache optimization and hotlink prevention in Linux system Detailed tutorial on Apache optimization and hotlink prevention in Linux system Feb 20, 2024 am 09:00 AM

The following is a detailed tutorial on Apache optimization and anti-hotlinking under Linux systems: Apache performance optimization: Enable compression: Enable Gzip compression in the Apache configuration file to reduce the size of transmitted data. LoadModuledeflate_modulemodules/mod_deflate.soAddOutputFilterByTypeDEFLATEtext/htmltext/plaintext/xmltext/cssapplication/javascript

See all articles