In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how SQL Server 2014 uses cursor loops to insert data into remote databases. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First, set up a linked server in the remote database.
Set up the corresponding table structure on the remote database.
Taking CompanyID as the condition of table insertion, the cursor is designed.
Use the following SQL to achieve the circular insertion of cursors, to achieve batch insertion of data into the target database, and to avoid large transaction operations in the database.
Declare @ CompanyID Varchar (20)
Declare Cur_Company CURSOR FOR
Select distinct CompanyID From Crm_Bas_Table
OPEN Cur_Company
FETCH NEXT FROM Cur_Company Into @ CompanyID
While @ @ FETCH_STATUS = 0
Begin
Insert Into [10.0.10.100]. [CRM_His_DB] .[dbo] .[Crm _ Bas_Table]
(CompanyID,BillNo,CustomerID)
Select CompanyID,BillNo,CustomerID
From Crm_Bas_Table with (nolock)
Where CompanyID = @ CompanyID
FETCH NEXT FROM Cur_Company Into @ CompanyID
End
CLOSE Cur_Company
DEALLOCATE Cur_Company
Thank you for reading! This is the end of this article on "how SQL Server 2014 uses cursor loops to insert data into a remote database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un