Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS Script Component or Script Task Write To Job History Log

  • I am using SQL server 2008 R2.
  • I have a scheduled job that executes an SSIS Package - running in SQL Agent.
  • I want to log messages that happen in the scheduled job.
  • I want to log messages from Script Component or Script Task.
  • I do not want to log ONLY errors, I want to log success messages such as "Processed X records".
  • I do not want to build custom tables or anything.
  • Ideally, I want to see these messages in the Job History log
like image 710
Simcha Khabinsky Avatar asked Oct 17 '25 23:10

Simcha Khabinsky


1 Answers

You can send messages directly to the Job History Log. It will show up as follows in the Job history log:

enter image description here

For Script Tasks use the following code:

Dts.Events.FireWarning(0, "Message header", "Message Body", String.Empty, 0)

For Script Component use the following code:

Dim myMetadata As IDTSComponentMetaData100
myMetadata = Me.ComponentMetaData
myMetadata.FireWarning(0, "Message Header", "Message Body", "", 0)

You will need to enable "Include step output in history (see below)

  • Right-Click on Job >> Steps >> Edit >> Properties >> Advanced >> Check "Include step output in history"

You will need to enable Warning Messages for the SSIS package (see below)

  • Right-Click on Job >> Steps >> Edit >> Properties >> Command Line Add "W" to /REPORTING

Enabling "Include step output in history":

enter image description here


Enabling Warning Messages:

enter image description here

like image 81
Simcha Khabinsky Avatar answered Oct 19 '25 12:10

Simcha Khabinsky