Vous êtes sur la page 1sur 15

Module 11

Extending SQL Server Integration


Services
Module Overview

• Using Scripts in SSIS


• Using Custom Components in SSIS
Lesson 1: Using Scripts in SSIS

• Introduction to Scripting in SSIS


• Using the Control Flow Script Task
• Demonstration: Implementing a Script Task
• Using the Data Flow Script Component
• Demonstration: Using a Script Component in a
Data Flow
Introduction to Scripting in SSIS

• Implement custom functionality with Visual Basic


or Visual C# code
• Configure properties in the package designer,
and develop code using the Visual Studio Tools
for Applications (VSTA) environment
• Scripts are precompiled for optimal execution
performance
• Two scripting scenarios
• Use the Script Task to implement a custom control flow
task
• Use the Script Component to implement a custom data
flow source, transformation, or destination
Using the Control Flow Script Task

1. Add the task to the control flow


• Configure properties and logging settings as required
2. Configure the task
• Language
• Entry point method
• Access to variables
3. Implement the code
• Use the Dts object to access package and runtime functionality
Public void Main()
{
Dts.Variables["User::MyVar"].Value =
Dts.Variables["System::StartTime"].Value.ToString();
Dts.Log("Package started:" +
(string)Dts.Variables["User::MyVar"].Value, 999, null);
Dts.TaskResult = (int)ScriptResults.Success;
}
Demonstration: Implementing a Script Task

In this demonstration, you will see how to:


• Configure a Script Task
• Implement a Script Task
Using the Data Flow Script Component

• Create a Source
• Configure output columns
• Implement CreateNewOutputRows method
MyOutputBuffer.AddRow();
MyOuputBuffer.Column1="Value for column 1";

• Create a Transformation
• Configure inputs and outputs
• Implement ProcessInputRow method for each input
Row.Column1=Row.Column1.ToUpper();

• Create a Destination
• Configure input columns
• Implement ProcessInputRow method for each input
MyDataStore.Add(Row.Column1, Row.Column2)
Demonstration: Using a Script Component in a
Data Flow

In this demonstration, you will see how to:


• Implement a Source
• Implement a Transformation
• Implement a Destination
Lesson 2: Using Custom Components in SSIS

• Introduction to Custom Components


• Implementing a Custom Component
• Installing and Using a Custom Component
Introduction to Custom Components

Extend SSIS package functionality by using


custom:
• Tasks
• Connection managers
• Log providers
• Enumerators
• Data flow components
Implementing a Custom Component

Add references to
required assemblies
and declare
namespaces

Use
attributes to Inherit from
provide the
design-time appropriate
information Use a key to
base class
sign the
assembly

Override the
base class
methods
Installing and Using a Custom Component

1. Copy the assembly to the DTS folder


2. Install the assembly in the global assembly
cache
3. Use the custom component in an SSIS package
Lab: Using Custom Scripts

• Exercise 1: Using a Script Task

Logon Information
Virtual machine: 20463C-MIA-SQL
User name: ADVENTUREWORKS\Student
Password: Pa$$w0rd

Estimated Time: 30 minutes


Lab Scenario

The senior database administrator has requested


that the data warehouse ETL process logs the
number of rows extracted from the staging
database and loaded into the data warehouse in
the Windows event log. You have decided to use a
custom script to accomplish this.
Module Review and Takeaways

• Review Question(s)

Vous aimerez peut-être aussi