What are exceptions handling functions used in procedure?

686    Asked by JoeShort in SQL Server , Asked on Jan 27, 2020
Answered by Joe Short

There are some system functions which help in exception tracking. These types of functions capture the error details and helps in checking the error in details:

Function name

Return data type

Use

ERROR_NUMBER()

INT

This function returns the error number by which error occurs. error numbers are maintained in a system error table. It will return null if this is called outside the catch

ERROR_STATE()

INT

This function will return the state at which error occurred.

ERROR_LINE()

INT

this function returns will return the line no. on which line the error has occurred.

ERROR_MESSAGE()

nvarhcar(4000)

This function will return the error text message because this error is caused.in case of user raised error it will be message given in raise_error message

ERROR_PROCEDURE()

Nvarchar(128)

This function will tell the procedure name in which the error is raised.

ERROR_SEVERITY()

INT

It will return the severity of the error (problem type) by which the error is raised

RAISERROR()

This function is used to raise a custom error by the user

RAISERROR(‘Message’,16,1)

GOTO()

This function is used to jump to a specific SQL statement with function name defined



Your Answer

Interviews

Parent Categories