替换SQL Server数据库中所有表的所有字段的某些内容--方法二
Jun 07, 2016 pm 02:54 PM替换SQL Server数据库中所有表的所有字段的某些内容 替换 表字段 内容 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
替换SQL Server数据库中所有表的所有字段的某些内容
替换 表字段 内容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='aa' --这里是你要替换的新字符 set @str2='bb' 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;

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What is the difference between HQL and SQL in Hibernate framework?

How does Go language implement the addition, deletion, modification and query operations of the database?

Detailed tutorial on establishing a database connection using MySQLi in PHP

How does Hibernate implement polymorphic mapping?

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

An in-depth analysis of how HTML reads the database

Tips and practices for handling Chinese garbled characters in databases with PHP
