Get column name when getting error information

I used a stored procedure and throws an exception when data is transferred with an error. I return to operator error by using the built-in functions, such as ERROR_NUMBER(), ERROR_MESSAGE(), ERROR_PROCEDURE().

But I also need to show which column in the table the problem occurs.

For example, a table Employeehas two fields of type EmpNameand EmpDate.

There EmpDateis DateTimea data type here. If I'm going to insert a value varchar, then it throws an exception like this:

Failed to convert date / time to varchar

using ERROR_MESSAGE(). I also need to get the column name caused by the error:EmpDate

Is there a built-in function similar to another ERROR-related function?

+4
source share

Source: https://habr.com/ru/post/1605669/


All Articles