Chapter 6 Quick Reference


Open table as spreadsheet

To

Do This

Implement custom code in Control Flow

In the Toolbox, drag the Script Task to the design surface of the Control Flow tab. Double-click the Script task and click Design Script on the Script page in the Script Task Editor dialog box. In the VSA Code Editor, implement your own code in the Main method and set the overall result to the Dts.TaskResult property. The Code Editor provides you with several features to make your coding work easy.

Implement custom data processing code inside of the Data Flow

In the Toolbox, expand Data Flow Transformations and drag Script Component to the design surface of the Data Flow tab. In the Select Script Component Type dialog box, select Source, Transformation, or Destination as the situation demands. On the Input page and the Inputs and Outputs page in the Script Transformation Editor dialog box, define the inputs and outputs of the Script component. Select the Script page and click Design Script. In the VSA Code Editor, implement a script code to work with the InputBuffer/OutputBuffer object.

Implement error-handling code in the script

Implement the TRYCATCHFINALLY statement inside your script code. If an error occurred in the Try block, the alternative code implemented in the Catch block will be executed. You can specify multiple Catch blocks, based on the type of Exception object. You can also create the Finally block to implement finalization code.

Provide messages to the Progress tab

From the Script task, call the appropriate method defined under the Dts.Events object. The Dts.Events object allows you to raise several kinds of events, such as Information, Progress, and Errors. From the Script component, use methods defined under the Me.ComponentMetadata object.

Write out verbose information to a log file

From the Script task, call the Dts.Log method with appropriate parameters. From the Script component, call the Me.ComponentMetadata.Log method inside the script code. To configure the log settings, change the Logging-Mode property of the Script task to Enable. Right-click anywhere on the design surface of the Control Flow tab and select Logging. In the Configure SSIS Logs dialog box, select the check box next to the package and the Script task to activate logging. On the Providers and Logs tab, add a log provider for text files and specify the file name. Select the check box to activate the provider. On the Details tab, select the check box next to the ScriptTaskLogEntry event so the SSIS engine listens to the message derived by the Dts.Log method.

Access the package variables

Right-click the design surface of the Control Flow tab and select Variables. Create a new variable in the Variables window. In the Script task, access the Dts.Variables object with the appropriate parameter name. You also need to set the variable name in either the ReadOnlyVariables property or the ReadWriteVariables property of the Script task. In the Script component, access the Me.Variables object. You also need to set the ReadOnlyVariables or ReadWriteVariables properties to use variables in the Script component.

Validate string data such as e-mail addresses

Use Regular Expressions. Call the Regex.IsMatch method with the string you would like to examine and the character patterns defined by Regular Expressions. If the string matches the patterns, the IsMatch method returns True. The Regex class is defined under the System.Text.Regular-Expressions namespace. Refer to the MSDN Web site to obtain detailed information about Regular Expressions.

Implement custom code using the ActiveX Script task

Create a new ActiveX Script task and implement script in the Script property. Specify the EntryMethod property if the script has a starter method. The ActiveX Script task is currently retained for backward compatibility, but use Script task if possible.




Microsoft SQL Server 2005 Integration Services Step by Step
MicrosoftВ® SQL Server(TM) 2005 Integration Services Step by Step
ISBN: 0735624054
EAN: 2147483647
Year: 2007
Pages: 152

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net