T-SQL Förbättringar TRY/CATCH BEGIN TRY BEGIN TRAN -- Constraint violations cause txn/batch-abort -- control to client INSERT TestTable1 VALUES (@a, @b) COMMIT TRAN END TRY BEGIN CATCH TRAN_ABORT ROLLBACK INSERT TestTable1_Violations VALUES (@a, @b, GETDATE()) RAISERROR ( Logged bad insert , 17, 1) WITH TRAN_ABORT END CATCH
{}