Thanks, Lynn! Here's a possible minor tweak that I think makes one less trip through the loop (unless the total number of rows we're deleting is an exact multiple of the batchsize):
Instead of:
while @batchsize 0
If we say:
declare @orgBatchSize bigint
set @orgBatchSize = @batchsize
while @batchsize = @orgBatchSize
This exits the loop as soon as the number of deleted rows is less than the batchsize (which will only happen when there's nothing left to delete). This could be a time-saver if the Where clause on the Delete is slow.