首页 > 数据库技术 > 详细

数据库所有表替换所有列的特定字符串

时间:2014-07-06 15:12:04      阅读:338      评论:0      收藏:0      [点我收藏+]

DECLARE
@TableName VARCHAR(119) DECLARE @TableID INT DECLARE @ColName VARCHAR(111) DECLARE Table_Cursor CURSOR FOR SELECT [name],id FROM sysobjects WHERE xtype=U; OPEN Table_Cursor; FETCH NEXT FROM Table_Cursor INTO @TableName,@TableID; WHILE(@@FETCH_STATUS=0) BEGIN DECLARE Columns_Cursor CURSOR FOR select [name] from [syscolumns] where [id] = @TableID OPEN Columns_Cursor; FETCH NEXT FROM Columns_Cursor INTO @ColName; WHILE(@@FETCH_STATUS=0) BEGIN EXEC(UPDATE +@TableName+ SET +@ColName+=replace(+@ColName+,‘‘lijinsm.cn‘‘,‘‘sdgow.cn‘‘)); EXEC(UPDATE +@TableName+ SET +@ColName+=replace(+@ColName+,‘‘400-111-1111‘‘,‘‘400-888-8888‘‘)); FETCH NEXT FROM Columns_Cursor INTO @ColName; END CLOSE Columns_Cursor; DEALLOCATE Columns_Cursor; FETCH NEXT FROM Table_Cursor INTO @TableName,@TableID; END CLOSE Table_Cursor; DEALLOCATE Table_Cursor;

 

 

数据库所有表替换所有列的特定字符串,布布扣,bubuko.com

数据库所有表替换所有列的特定字符串

原文:http://www.cnblogs.com/dashi/p/3825525.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!