You are on page 1of 16

Module 12

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
Public void
void Main()
Main()
{{
Dts.Variables["User::MyVar"].Value
Dts.Variables["User::MyVar"].Value ==
Dts.Variables["System::StartTime"].Value.ToString();
Dts.Variables["System::StartTime"].Value.ToString();
Dts.Log("Package
Dts.Log("Package started:" ++
started:"
(string)Dts.Variables["User::MyVar"].Value,
(string)Dts.Variables["User::MyVar"].Value, 999,
999, null);
null);
Dts.TaskResult
Dts.TaskResult == (int)ScriptResults.Success;
(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();
MyOutputBuffer.AddRow();
MyOuputBuffer.Column1="Value
MyOuputBuffer.Column1="Value for
for column
column 1";
1";

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

• Create a Destination
• Configure input columns
• Implement ProcessInputRow method for each input
MyDataStore.Add(Row.Column1,
MyDataStore.Add(Row.Column1, Row.Column2)
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 using Microsoft.SqlServer.Dts.Runtime;


required namespace MyCustomSSISComponent
assemblies and
{
[DtsTask(DisplayName="My Custom Task",
declare UITypeName ="My Custom Task",
namespaces
RequiredProductLevel=
DTSProductLevel.None)]
• Use attributes to public class MyCustomTask: Task
{
provide design- public override DTSExecResult Execute
time information (Connections ,
VariableDispenser variableDispenser,
• Inherit from the IDTSComponentEvents componentEvents,
IDTSLogging log, object transaction)
appropriate base {
class //Code to execute the task goes here
}
• Override the base }
class methods }

• Sign the assembly


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: 20767C-MIA-SQL
User name: ADVENTUREWORKS\Student
Password: Pa55w.rd

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 task.
Lab Review

Having completed this lab, you will now be able to:


• Use a Script task
Module Review and Takeaways

• Review Question(s)

You might also like