Considering the following executed command
BEGIN TRY
-- Generate a divide-by-zero error.
SELECT 1/0;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
GO
Your response will be:
ErrorNumber
8134
ErrorSeverity
16
ErrorState
1
ErrorProcedure
NULL
ErrorMessage
Divide by zero error encountered.
Is there any way to get which execution block was executed to generate this exception?
I wanted the answer to be:
Command
'SELECT 1/0;'