I want to log errors from my odbc-connection. For example it should be possible to see a simple syntax error. This works great:
BEGIN TRY
Declare @t as money
set @t = 1/0
END TRY
BEGIN CATCH
Print ERROR_MESSAGE();
END CATCH
The query returns the error message. Works great.
This also works, because there seems to be a red message?
BEGIN TRY
EXEC('Selllect 1/0 as Column1 ') AT VERBINDUNGSSERVERNAME
END TRY
BEGIN CATCH
Print ERROR_MESSAGE();
END CATCH
Screenshot:
But unfortunately not every ODBC error was logged. But I want to log all of these odbc errors. The next example is not logged by the try-catch block:
I'm using a lot of query stacks and it would be helpful to get a valid error log :-) Thank you!