首先,在 MS SQL Server Management Studio 中,我启用了SET IMPLICIT_TRANSACTIONS
选项。我不确定这是否与我看到的这种行为有关。
我有以下脚本:
BEGIN TRANSACTION;
WITH
DocLinksTmp
AS
(
select *,
row_number() over (partition by col1, col2 order by col1) as [RowNumber]
from doctable
)
DELETE
DocLinksTmp
WHERE
RowNumber > 1
GO
COMMIT
COMMIT
print @@trancount
保留这两个COMMIT
语句,打印命令打印 0。当我删除一个COMMIT
时,打印语句打印 1。
任何想法为什么会发生这种情况?