Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement batch updates with SQLServer

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to achieve batch updates in SQLServer". 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 to achieve batch updates in SQLServer".

1. Directly use top N to realize batch update

Update top (1000) table1 set SysNo = 0, UpdateTime = getdate () where Status not in (- 1 and SysNo 2) and StockStatus 2 and isnull (CaiSysNo,0) = 0 and SysNo = 1

2. Batch update with intermediate table

Select SysNo into table1_temp01

FROM table1

WHERE EXISTS (SELECT 1 FROM table1_History..table1_History a WHERE a.SysNo=table1.SysNo)

UPDATE TOP (5000)

From table1

Where SysNo in

(select SysNo from table1_temp01)

Thank you for your reading, the above is the content of "how to achieve batch update of SQLServer". After the study of this article, I believe you have a deeper understanding of how to achieve batch update of SQLServer, 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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report