Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
TRUNCATE TABLE tmp
BEGIN TRAN
BEGIN TRY
INSERT INTO dbo.tmp( c1 ,c2 ,c3 )
VALUES(1,1,1)
SELECT 1/0
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0 BEGIN ROLLBACK END
END CATCH
IF @@TRANCOUNT > 0 BEGIN COMMIT END
注,@@TRANCOUNT:
1)BEGIN TRANSACTION 语句将 @@TRANCOUNT 加 1。
2)ROLLBACK TRANSACTION 将 @@TRANCOUNT 递减到 0,
但 ROLLBACK TRANSACTION savepoint_name 除外,它不影响 @@TRANCOUNT。
3)COMMIT TRANSACTION 或 COMMIT WORK 将 @@TRANCOUNT 递减 1。