Hi guys
This is just for practice purposes to understand how to update records in batches.
I have a code for this but I am not sure whether it will perform the way I need it.
My requirement :- To update 900 records in a batch of 300. So when 300 records are updated the sql server should wait for a min and then update the next 300 and then the next 300 . I want to do it in only one while loop. No timestamp required
declare
@bottom int
declare
@top int
declare
@total int
declare
@records int
set
@records=300
set
@bottom=1
set
@top=@records
set
@total=(selectcount(*)from[ODB_Loading]..Sheet1)
while
@bottom <=@total
begin
updatea
setemail_address=null
fromodb..customer_address a
join
odb..customer_profile b
ona.customer_profile_id=b.customer_profile_id
andb.customer_id=(selectcustomer_idfromodb_loading..Sheet1whereid=@bottom)
where@recordsbetween@bottomand@top
set
@bottom=@bottom+1
set
@top=@top+@records
end
You advise will be much appreciated
Farhan Jamil