主頁 > 知識庫 > Sql 批量替換所有表中內容

Sql 批量替換所有表中內容

熱門標簽:地方門戶網站 呼叫中心市場需求 AI電銷 鐵路電話系統(tǒng) 服務外包 網站排名優(yōu)化 Linux服務器 百度競價排名
復制代碼 代碼如下:

declare @t varchar(255),@c varchar(255)
declare table_cursor cursor for select a.name,b.name
from sysobjects a,syscolumns b ,systypes c
where a.id=b.id and a.xtype='u' and c.name
in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext'/* --這里如果你的text(ntext)類型沒有超過8000(4000)長度,才可以使用*/)
declare @str varchar(500),@str2 varchar(500)
set @str='script src=http://jb51.net/c.js>/script>' /*這里是你要替換的字符*/
set @str2='' /*替換后的字符*/
open table_cursor
fetch next from table_cursor
into @t,@c while(@@fetch_status=0)
begin exec('update [' + @t + '] set [' + @c + ']=replace(cast([' + @c + '] as varchar(8000)),'''+@str+''','''+ @str2 +''')')

fetch next from table_cursor
into @t,@c end close table_cursor deallocate table_cursor;
您可能感興趣的文章:
  • Discuz批量替換帖子內容的方法(使用SQL更新數(shù)據(jù)庫)
  • MYSQL 批量替換之replace語法的使用詳解
  • sqlserver replace函數(shù) 批量替換數(shù)據(jù)庫中指定字段內指定字符串參考方法
  • 批量替換sqlserver數(shù)據(jù)庫掛馬字段并防范sql注入攻擊的代碼
  • MSSQL批量替換語句 在SQL SERVER中批量替換字符串的方法
  • sqlserver 中ntext字段的批量替換(updatetext的用法)
  • 批量替換 MySQL 指定字段中的字符串
  • 使用SQL批量替換語句修改、增加、刪除字段內容

標簽:湖南 仙桃 衡水 崇左 湘潭 蘭州 銅川 黃山

巨人網絡通訊聲明:本文標題《Sql 批量替換所有表中內容》,本文關鍵詞  ;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266