In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how mssql replaces the entire database in batches". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how mssql replaces the entire database in batches".
Declare cur cursor FOR
SELECT name,id FROM sysobjects WHERE xtype=U
Open cur
Fetch next FROM cur INTO @ tableName,@tbID
While @ @ fetch_status=0
Begin
Declare cur1 cursor FOR
-- xtype in (231, 167, 239, 175, 99) is of char,varchar,nchar,nvarchar,ntext type.
SELECT name FROM syscolumns WHERE xtype IN (231, 167, 239, 175, 99) AND
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)), + @ Str1+,+@Str2+) where [+ @ columnName+] like
Statements like 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 > 0
Begin
Print table:, column: + @ columnName+ is updated + convert (varchar (10), @ iRow) + records
End
Fetch next FROM cur1 INTO @ columnName
End
Close cur1
Deallocate cur1
Fetch next FROM cur INTO @ tableName,@tbID
End
Print has a total of + convert (varchar (10), @ iResult) + records updated!
Close cur
Deallocate cur
SET nocount off
Thank you for reading, the above is the content of "how mssql replaces the entire database in batches". After the study of this article, I believe you have a deeper understanding of how mssql replaces the entire database 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.