A personal repository of technical notes. - CSC

How to Write Output to SQL Server Job History Log


Need to generate custom output in job history of an operating system job type.


1) Check this box in SQL Server Management Studio: Job Step Properties / Advanced / Include step output in history

2) Generate output in job's executable. C#.NET example:

private static void TestSqlJobOutput()
       System.Console.WriteLine("Sample Error Message 1"); // Shows up in SQL Server job history log.
       Environment.ExitCode = 1; // Causes SQL Server job step to fail when application ends.

No comments:

Post a Comment