SELECT *
FROM [Production].[Product]
BEGIN TRY
BEGIN TRAN;
UPDATE [Production].[Product]
SET Color = 'Off White'
SELECT *
FROM [Production].[Product]
SELECT @@TRANCOUNT AS 'Transaction Count'
COMMIT TRAN;
END TRY
BEGIN CATCH
ROLLBACK TRAN;
END CATCH;
SELECT *, @@TRANCOUNT AS 'Transaction Count'
FROM [Production].[Product]
我没有收到任何错误,但是改变并没有像他们应该的那样回滚......有什么想法吗?
答案 0 :(得分:0)
SELECT *
FROM [Production].[Product]
BEGIN TRAN;
SAVE TRAN Product1;
UPDATE [Production].[Product]
SET Color = 'Off White'
SELECT *
FROM [Production].[Product]
SELECT @@TRANCOUNT AS 'Transaction Count'
ROLLBACK TRAN Product1;
COMMIT TRAN;
SELECT *
FROM [Production].[Product]
SELECT @@TRANCOUNT AS 'Transaction Count'
这就像我需要它一样,以为我会分享财富!〜
编辑1:忘记包含对代码的重要更改,我只是人类!