sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

Add a parameter to silence output, and link operations to the job executing them

Open PABluesMan opened this issue 4 months ago • 2 comments

We are constantly being asked to report on errors encountered during index maintenance, backups, etc. For all jobs other than the ones using the Hallengren scripts, we can merely go into the [msdb].[dbo].[sysjobhistory] table to retrieve the error message. However, because the Hallengren scripts overflow the [sysjobhistory].[message] field's 4000 character limit, we end up with absolutely zero useful information from there.

In addition, the CommandLog table does not provide a link to the job that executed the statement. The bests we can do is to approximate based in the dates and times, but not all of our servers are running in Universal Coordinated Time. As a result, we have timestamps from server A that are four or five hours ahead of the timestamps on server B. This not only adds a layer of complexity in resolving the date/time differences, it makes implementing any sort of centralized or automated solution exceedingly difficult.

My suggestions are these:

  1. Add a parameter allowing the calling process to silence all the informational messages that get written to [sysjobhistory] (the listing of parameter values, operating system version information, and the like). Ideally, this parameter would squelch all messages except true warning or error messages.
  2. Add a column to the [CommandLog] table that allows the records there to be linked to the calling process (a job GUID, for example).

PABluesMan avatar Aug 12 '25 15:08 PABluesMan

Errors are in the logfile, because of the limit.

Stiffboard avatar Aug 12 '25 15:08 Stiffboard

The log files are of little help because of the fact that we cannot query them. In addition, using text files makes it virtually impossible to set up any sort of centralized repository we could use to analyze trends.

PABluesMan avatar Nov 20 '25 18:11 PABluesMan