I made a program to perform insert/delete on a table(main table)…My program also write a log for the operations (insert/delete) performed on this this table in another table(audit log table)…
The program write the log for every successful or failed operation performed on main table in audit log table…I have one field in my audit log table in which i want to move the reason of failure of the operation, if the operation will fail for main table..
I know the reason for sqlcodes like -503 , +100 , -803 …But i want to insert reason for every SQL code possible…
Is there any variable in T-SQL , from where i can insert the sql error text message into the table..??
Or there is any other way to do it ?
Try something like this:
This assumes the LOG_TABLE has only two columns, the first column for the error number, the second column for the error message. You can use these functions: