I’m changing some code to take advantage of TRY … CATCH in SQL Server 2005. What successful strategies have you found for using it?
I’m thinking of creating a stored proc which calls the system functions which give details of the error, rolls back any open transaction and raises an error. Is there a better way?
I’m using TRY…CATCH extactly the way you described, using
RAISERRORat the end of the CATCH-block to pass the error back to the caller. This also allows you to handle certain error codes within the stored procedure as well.