As like in C#, a new function THROW is introduced in SQL 2012 to make try and catch error method more simple instead of using RAISEERROR.
BEGIN TRY BEGIN TRANSACTION -- Start the transaction
DELETE FROM Customers
WHERE EmployeeID = @EmpID -- Commit the change
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
THROW
END CATCH
BEGIN TRY BEGIN TRANSACTION -- Start the transaction
DELETE FROM Customers
WHERE EmployeeID = @EmpID -- Commit the change
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
THROW
END CATCH
No comments:
Post a Comment