Want to change this piece of SQL query into a loop version which
Could Select-Insert records by 1000 items per iteration.
On each iteration want to get a print to see what was the last inserted item.
The Code :
INSERT INTO [tData2]
(
[Key],
Info1,
Info2
)
SELECT
[Key], --the Id
Info1,
Info2
FROM
[tData]
Edit :
(There were other conditions to limit the insertion, which aren’t related to the question)
The Bulk-Insertion logic will not be changed, just we shrink the database pieces to be inserted.
Instead of inserting the whole table we Bulk-Insert 10000 items per iteration and could get a simple report on it also.
your help is really appreciated.
Here’s some sample code I quickly put together for you to experiment with. This doesn’t use a cursor (uses while instead) but you could build it that way as well. There are some performance optimizations that you could make but only you can judge that. YMMV