SQL Server 2000删除大数据量,解决阻塞---------循环,删除小量数据

declare @i int 
declare @usedate datetime
set @i=19582000
while @i<30231929
begin
select @usedate = getdate()

delete from servicesubscription where subscriptionid <= @i and subscriptionid<=30231928

insert into test..aaamovielogs values(@i,@usedate,getdate(),@@rowcount)
set @i=@i+1000
if(@i>30231928)
set @i=30231928

WAITFOR DELAY '00:00:05'
end

 

posted @ 2012-02-09 15:29  大笑江湖  阅读(294)  评论(0编辑  收藏  举报