6
Considering the following command executed
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
The answer to it 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 wish the answer was:
Command
'SELECT 1/0;'
You can not do this, because the application that I will apply this model are several commands with various records.
– Jhonathan
yes, but how many errors will return? specify your question better.
– Marco Souza
I want him to return any errors he gives.
– Jhonathan
And what’s the problem? Just use the variable and concatenate
– Marco Souza