Implementing a SQL Data Warehouse — Question 45
You are developing a Microsoft SQL Server Integration Service (SSIS) package. You enable the SSIS log provider for the Windows event log. You configure the package to use the ScriptTaskLogEntry event. You create a custom Script task.
You need to ensure that when the script completes, it writes the execution status to the event log on the server that hosts SSIS.
Which code segment should you add to the Script task?
Answer options
- A. System.Diagnostics.EventLog.WriteEntry("SSIS", "Script executed with return result" + ScriptResults.Success, System.Diagnostics.EventLogEntrytype.Information)
- B. System.Diagnostics.EventLog.WriteEntry("SSIS", "Script executed with return result" + Dts.TaskResult, System.Diagnostics.EventLogEntryType.Information)
- C. Dts.TaskResult = (int)ScriptResults.Failure
- D. Dts.Events.FireInformation(0, "SSIS", "Script executed with return result" + Dts.TaskResult, String.Empty, 0)
Correct answer: B
Explanation
The correct answer is B because it correctly logs the task's execution result using Dts.TaskResult, which reflects the status of the script. Option A incorrectly uses ScriptResults.Success, which does not capture the actual task's result. Option C only sets the task result to failure without logging it, and option D fires an information event instead of writing to the event log.