I\'m using SQL Server 2005. I created a stored procedure which works most of the time, but I found an instance of where it doesn\'t do what I want.
Currently, the c
You could use a general Try/Catch and then construct more details about the error within the CATCH section e.g.
DECLARE @DetailedErrorDesc VARCHAR(MAX)
BEGIN TRY
--tsql code goes here
END TRY
BEGIN CATCH
SELECT @DetailedErrorDesc =
CAST(ERROR_NUMBER() AS VARCHAR) + ' : '+
CAST(ERROR_SEVERITY() AS VARCHAR) + ' : ' +
CAST(ERROR_STATE() AS VARCHAR) + ' : ' +
ERROR_PROCEDURE() + ' : ' +
ERROR_MESSAGE() + ' : ' +
CAST(ERROR_LINE() AS VARCHAR);
--Now you can decide what to do with the detailed error message....return it or log it etc
END CATCH