SQL Server > Error Handling

Get more details about an error occurred in SQL Server

How to get more details about an error occurred in SQL Server?


To get more error related values in the CATCH block, try to use error methods, used in the SELECT statement inside the BEGIN CATCH block.

BEGIN TRY
       SELECT 'ITFunda'/0
END TRY
BEGIN CATCH
       SELECT ERROR_MESSAGE(), ERROR_NUMBER(), ERROR_PROCEDURE(),
ERROR_SEVERITY(), ERROR_STATE(), ERROR_LINE();
       -- THROW 50001, 'Always use integer to divide by', 1 (to throw error, un
comment it)
END CATCH

 Views: 1199 | Post Order: 100



Write for us