批量刪除MSSQL被掛JS木馬語句

2021-09-06 08:15:45 字數 1987 閱讀 2968

declare

@delstr

varchar(8000

)set

@delstr='

'set nocount on

declare

@tablename

nvarchar(100),@columnname

nvarchar(100),@tbid

int,@irow

int,@iresult

intdeclare

@sql

nvarchar(500

)set

@iresult=0

declare cur cursor

forselect name,id from sysobjects where xtype='u

'open

curfetch

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

>

0begin

print'表:

'+@tablename+'

,列:'

+@columnname+'

被更新'

+convert(varchar(10),@irow)+

'條記錄;

'end

fetch

next

from cur1 into

@columnname

endclose

cur1

deallocate

cur1

fetch

next

from cur into

@tablename,@tbid

endprint

'資料庫共有'+

convert(varchar(10),@iresult)+

'條記錄被更新!!!

'close

curdeallocate

curset nocount off

上面就是批量刪除資料庫中所有字串後面被掛js木馬的批量刪除語句,記錄下。

MSSQL級聯刪除問題

現mssql設定級聯刪除時候有個問題,簡單說就是 乙個表中不能兩次使用外來鍵的級聯刪除或級聯更新。錯誤提示是 將 foreign key 約束 fk effect.效應例項 effect.效應 引入表 effect.效應例項 中將導致迴圈或多重級聯路徑。請指定 on delete no action...

Django 刪除 批量刪除

刪除 修改與刪除等的操作,都從前台傳來乙個id獲取後執行 class delete two cate view def get self,request id request.get.get id try two twocate.objects.filter id id delete except ...

hibernate批量修改,批量刪除

在hibernate應用中如何處理批量更新和批量刪除?批量更新是指在乙個事務中更新大批量資料,批量刪除是指在乙個事務中刪除大批量資料。以下程式直接通過hibernate api批量更新customers表中年齡大於零的所有記錄的age欄位 tx session.begintransaction it...