The Script Component is one of the most important, and powerful component in SQL Server Integration Services. It can act as a Source, Transformation, and Destination. In this article we will show you, How to use the SSIS Script Component as Transformation with practical example. Though we are using very simple example for the demonstration purpose, it is designed for doing robust work. Work that is not possible for the built-in transformations, or we can use this component to combine the work of multiple transformation in one place.
You can also look into following links:
Before we start creating the SSIS package, Let us see the SQL table and the data that we are going to use.
Configuring SSIS Script Component as Transformation
STEP 1: Drag and drop the Data Flow Task from toolbox to control flow region, and rename it as the SSIS Script Component as Transformation.
Double click on the data flow task will open the data flow tab.
From the below screenshot you can observe that, We selected [SSIS Tutorials] Database as source database and [MyEmployees] table as source table
STEP 3: Click on columns tab to verify the columns. In this tab we can uncheck the unwanted columns also.
STEP 4: Drag and drop Script Component from SSIS toolbox to data flow region. Once you drop the Script component, a new pop up window called Select Script Content Type will be opened as shown below. Here we want to demonstrate about the ssis script component as a transformation so, we are selecting the Transformation option
STEP 5: Double click on the Script component will open the following editor to configure the properties. Though there are many properties, we will explore few important properties that we use in our daily coding
- Name: Please provide the Unique Name
- Description: Briefly describe the Script Functionality. It is always a good practice to provide the valid description.
- ReadOnlyVariables: Please select the variables that you want to use in the Script, and they may be user defined variables or System default variables. Remember, variables selected as ReadOnlyVariables are used for Read-only purpose (we can’t alter them)
- ReadWriteVariables: Please select the variables you want to use in the Script. Remember, variables selected as ReadWriteVariables can be altered according to our requirement
STEP 6: Within the Input Columns tab, you can cross check the input columns.
STEP 7: Within the Input and Outputs tab, Go to Output Columns, and under output columns we are going add one column called FullName using Add Column button
Here we added the FullName Column, and then changed the Data type from Integer (default) to string [DT_STR]
STEP 8: Within the Script tab, please click on the Edit Script.. button to write the actual C# Script
TIP: You can change the language to VB.Net using ScriptLanguage property.
Once you click on the Edit Script, it will open the main.cs class file to write the C# code. Please write your custom code inside the Input0_ProcessInputRow(Input0Buffer Row) function
STEP 9: Add your custom C# code here. For this example, we are concatenating First name, Last Name, and then we are converting the First Letter to Uppercase.
Code that we used in the above screenshot is:
public override void Input0_ProcessInputRow(Input0Buffer Row)
* Add your code here
string name = Row.FirstName + " " + Row.LastName;
Row.FullName = FirstLetterUppercase(name);
// Function to Convert the First Character to UpperCase
private string FirstLetterUppercase(string name)
// Check whether String is empty.
// Converting First Character to Upper Case.
return char.ToUpper(name) + name.Substring(1);
STEP 10: Once you finished editing the Script, Please close the main.cs file. Next, drag and drop OLE DB Destinations on to the data flow region, and then drag the script component Output Arrow to this new OLE DB Destination
STEP 11: Double click on OLE DB Destination will open the OLE DB Destination Editor. Please Select the OLE DB Connection manager that you already created. Here we are selecting the [SSIS Script Component as Transformation] table present in the [SSIS Tutorials] Database.
STEP 12: Click on Mappings tab to check whether the source columns are exactly mapped to the destination columns.
Click OK to finish creating our Package.
STEP 13: Right click on the SSIS Script Component as Transformation Package in the Solution Explorer, and select Execute Package.
From the above screenshot you can observe that our Package has executed successfully. Let’s open the SQL Server Management Studio and write the following query to view the data
USE [SSIS Tutorials]
FROM [SSIS Script Component as Transformation]
Thank you for Visiting Our Blog