//Insert Data into chunks in database
declare @minID int
declare @maxID int
declare @batchStart int
declare @batchSize int
set @batchSize = 25000
select @minID = min(id), @maxID = max(id)
from sourceTable
set @batchStart = @minID
while @batchStart <= @maxID begin
insert into DestinationTable(....)
select ...
from sourceTable s
where s.id between @batchStart and @batchStart + @batchSize - 1
set @batchStart = @batchStart + @batchSize
end
No comments:
Post a Comment
Your comment is pending for approval