Declare @i int
Begin tran
insert into TAB1 select * from
TAB2 where DateTime<@BKDateTime
while Exists(select top 1 0 from TAB1 where DateTime<@BKDateTime)
begin
Delete top (1000) from TAB2 where datetime<@BKDateTime
Set @i=@i+1
Print Convert(varchar(10),@i)
end
commit tran
数据量大时,系统来不及响应SSMS,这比较正常。就像你有时开个IE,里面加载个大点的东西,然后IE停止响应,过一会就好了一样。
然后再讲保留的数据导回来。