TRY
BEGIN TRANSACTION
-- Update blah blah blah
-- If we got to this point, we are good
COMMIT
END TRY
BEGIN
-- Thank you GuysFromRolla for this code.
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception.
--note: * I have heard ASP.NET will give the Raiserror message...
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
SELECT @ErrMsg = ERROR_MESSAGE(),@ErrSeverity = ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
END
No comments:
Post a Comment