Export (0) Print
Expand All
5 out of 8 rated this helpful - Rate this topic

Script Task

The Script task provides code to perform functions that are not available in the built-in tasks and transformations that SQL Server Integration Services provides. The Script task can also combine functions in one script instead of using multiple tasks and transformations. You use the Script task for work that must be done once in a package (or once per enumerated object), instead than once per data row.

You can use the Script task for the following purposes:

  • Access data by using other technologies that are not supported by built-in connection types. For example, a script can use Active Directory Service Interfaces (ADSI) to access and extract user names from Active Directory.

  • Create a package-specific performance counter. For example, a script can create a performance counter that is updated while a complex or poorly performing task runs.

  • Identify whether specified files are empty or how many rows they contain, and then based on that information affect the control flow in a package. For example, if a file contains zero rows, the value of a variable set to 0, and a precedence constraint that evaluates the value prevents a File System task from copying the file.

If you have to use the script to do the same work for each row of data in a set, you should use the Script component instead of the Script task. For example, if you want to assess the reasonableness of a postage amount and skip data rows that have very high or low amounts, you would use a Script component. For more information, see Script Component.

If more than one package uses a script, consider writing a custom task instead of using the Script task. For more information, see Developing a Custom Task.

After you decide that the Script task is the appropriate choice for your package, you have to both develop the script that the task uses and configure the task itself.

The Script task uses Microsoft Visual Studio Tools for Applications (VSTA) as the environment in which you write the scripts and the engine that runs those scripts.

VSTA provides all the standard features of the Visual Studio environment, such as the color-coded Visual Studio editor, IntelliSense, and Object Explorer. VSTA also uses the same debugger that other Microsoft development tools use. Breakpoints in the script work seamlessly with breakpoints on Integration Services tasks and containers. VSTA supports both the Microsoft Visual Basic 2008 and Microsoft Visual C# 2008 programming languages.

To run a script, you must have VSTA installed on the computer where the package runs. When the package runs, the task loads the script engine and runs the script. You can access external .NET assemblies in scripts by adding references to the assemblies in the project.

NoteNote

Unlike earlier versions where you could indicate whether the scripts were precompiled, all scripts are precompiled in SQL Server 2008 Integration Services (SSIS). When a script is precompiled, the language engine is not loaded at run time and the package runs more quickly. However, precompiled binary files consume significant disk space.

You can configure the Script task in the following ways:

  • Provide the custom script that the task runs.

  • Specify the method in the VSTA project that the Integration Services runtime calls as the entry point into the Script task code.

  • Specify the script language.

  • Optionally, provide lists of read-only and read/write variables for use in the script.

You can set these properties through SSIS Designer or programmatically.

Configuring the Script Task in the Designer

The following table describes the ScriptTaskLogEntry event that can be logged for Script task. The ScriptTaskLogEntry event is selected for logging on the Details tab of the Configure SSIS Logs dialog box. For more information, see Implementing Logging in Packages and Custom Messages for Logging.

Log entry

Description

ScriptTaskLogEntry

Reports the results of implementing logging in the script. The task writes a log entry for each call to the Log method of the Dts object. The task writes these entries when the code is run. For more information, see Logging in the Script Task.

For more information about the properties that you can set in SSIS Designer, click one of the following topics:

For more information about how to set these properties in SSIS Designer, click the following topic:

Configuring the Script Task Programmatically

For more information about programmatically setting these properties, click the following topic:

Integration Services icon (small) Stay Up to Date with Integration Services

For the latest downloads, articles, samples, and videos from Microsoft, as well as selected solutions from the community, visit the Integration Services page on MSDN or TechNet:

For automatic notification of these updates, subscribe to the RSS feeds available on the page.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.