在SQL Server中,这将产生多少个事务?
DECLARE @deleted BIGINT
SET @deleted = 100000
WHILE @deleted = 100000
BEGIN
DELETE TOP(100000) FROM MYTABLE WITH (ROWLOCK)
where Col1 = 7048 and COL2 = 39727 and Col3 = 0
SET @deleted = (SELECT @@ROWCOUNT)
END
如果我在运行10分钟后取消,它是否需要回滚?
如果我不想在取消后回滚超过一次迭代,添加一个开始事务和结束事务会解决这个问题吗?
如果我将其放入存储过程中,是否会有任何区别?