Script Task Examples
The Script task is a multi-purpose tool that you can use in a package to fill almost any requirement that is not met by the tasks included with Integration Services. This topic lists Script task code samples that demonstrate some of the available functionality.
If you want to create tasks that you can more easily reuse across multiple packages, consider using the code in these Script task samples as the starting point for custom tasks. For more information, see Developing a Custom Task.
In This Section
This section contains code examples that demonstrate various uses of the .NET Framework classes that you can incorporate into an Integration Services Script task:
Detecting an Empty Flat File with the Script Task
Checks a flat file to determine whether it contains rows of data, and saves the result to a variable for use in control flow branching.
Gathering a List for the ForEach Loop with the Script Task
Gathers a list of files that meet user-specified criteria, and populates a variable for later use by the Foreach from Variable Enumerator.
Querying the Active Directory with the Script Task
Retrieves user information from Active Directory based on the value of an Integration Services variable, by using classes in the System.DirectoryServices namespace.
Monitoring Performance Counters with the Script Task
Creates a custom performance counter that can be used to track the execution progress of an Integration Services package, by using classes in the System.Diagnostics namespace.
Working with Images with the Script Task
Compresses images into the JPEG format and creates thumbnail images from them, by using classes in the System.Drawing namespace.
Finding Installed Printers with the Script Task
Locates installed printers that support a specific paper size, by using classes in the System.Drawing.Printing namespace.
Sending an HTML Mail Message with the Script Task
Sends a mail message in HTML format instead of plain text format.
Working with Excel Files with the Script Task
Lists the worksheets in an Excel file and checks for the existence of a specific worksheet.
Sending to a Remote Private Message Queue with the Script Task
Sends a message to a remote private message queue.
The following topics also contain code examples for use with the Script task:
Using Variables in the Script Task
Asks the user for confirmation of whether the package should continue to run, based on the value of a package variable that may exceed the limit specified in another variable.
Connecting to Data Sources in the Script Task
Retrieves a connection or connection information from connection managers defined in the package.
Raising Events in the Script Task
Raises an error, a warning, or an informational message based on the status of the Internet connection on the server.
Logging in the Script Task
Logs the number of items processed by the task to enabled log providers.