How Sql replaces the contents of all tables in batches
This article mainly explains how Sql replaces all the contents in the table in batches. The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how Sql replaces all the contents in the table in batches.
The copy code is as follows:
Declare @ t varchar, @ c varchar @ declare table_cursor cursor for select a.name from sysobjects an and c.name in syscolumns b, systypes c where a.id=b.id and a.xtypepaperu' and c.name in ('char',' nchar',' nvarchar', 'varchar','text','ntext'/*-- here if your text (ntext) type does not exceed 8000 (4000) length You can only use * /) declare @ str varchar, @ str2 varchar @ str='' / * here is the character you want to replace * / set @ str2='' / * the replaced character * / open table_cursor fetch next from table_cursor into @ t while (@ @ fetch_status=0) begin exec ('update [' + @ t +'] set ['+ @ c +'] = replace (['+ @ c +'] as varchar (8000)) '' + @ str+''','''+ @ str2 +')') fetch next from table_cursor into @ t recorder end close table_cursor deallocate table_cursor Thank you for your reading, the above is the content of "how Sql replaces all table contents in batches". After the study of this article, I believe you have a deeper understanding of how Sql replaces all table contents in batches, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!