Blaise ZARKA · Feb 4, 2016

How to export SQL errors to a text file?


Do you know how to export SQL errors to a text file from a terminal session in Caché?


2 0 3 230
Log in or sign up to continue


To be more precise, I'm doing a data migration with the management portal wizard.

I get SQL errors I would like to export.

Hi Blaise. There is query ErrorLog in %CSP.UI.System.BackgroundTask class so you can print errors like follows:

USER>do ##class(%ResultSet).RunQuery("%CSP.UI.System.BackgroundTask","ErrorLog",3932)

3932 here is task id.

And print errors to file:

USER>set file="c:\temp\sqlerrors.txt"
USER>open file:"NW":5
USER>use file do ##class(%ResultSet).RunQuery("%CSP.UI.System.BackgroundTask","ErrorLog",3932)
USER>close file

Notice that %CSP.UI.System.BackgroundTask is marked for internal use only.