SET ROWCOUNT 1000 Delete from Product_tbl where ProductID = 108 WHILE @@ROWCOUNT>0 Delete from Product_tbl where ProductID = 108 SET ROWCOUNT 0sql循环 哈好研究
-- Delete records with every 1000 deletes a commit declare @loop int, @tel int select @loop = count(*) / 1000 + 1 from demo set @tel = 0 while @tel < @loop begin begin transaction delete demo from (select top 1000 * from demo) as T1 where demo.date < dateadd(m,-1,getdate()) commit transaction set @tel = @tel + 1 end 上面是循环删除 的另一种方法
Delete from Product_tbl where ProductID = 108
WHILE @@ROWCOUNT>0
Delete from Product_tbl where ProductID = 108
SET ROWCOUNT 0用循環
set rowcount 行数 这个可以根据你的执行一次的时间进行设定。
Delete from Product_tbl where ProductID = 108
WHILE @@ROWCOUNT>0
Delete from Product_tbl where ProductID = 108
SET ROWCOUNT 0sql循环
哈好研究
declare @loop int, @tel int select @loop = count(*) / 1000 + 1 from demo set @tel = 0 while @tel < @loop begin begin transaction delete demo from (select top 1000 * from demo) as T1 where demo.date < dateadd(m,-1,getdate()) commit transaction set @tel = @tel + 1 end
上面是循环删除 的另一种方法