Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

SSIS Script Component as Source

by suresh

In this article, we will show how to use the SSIS Script Component as Source with a practical example. You can also look into the following links:

  • SSIS Script Component as Transformation
  • SSIS Script Component as Destination

Configuring SSIS Script Component as Source

STEP 1: Drag and drop the Data Flow Task from the toolbox to control flow region, and rename it as the SSIS Script Component as Source.

SSIS Script Component as Source 1

Double click on it will open the data flow tab.

STEP 2: Drag and drop Script Component from SSIS toolbox to data flow region. Once you drop the Script component on the data flow region, a new pop up window called Select Script Content Type will open. In this example we want to demonstrate about the SSIS script component as a source so, we are selecting the Source option

SSIS Script Component as Source 2

STEP 3: Double click on the Script component will open the following editor to configure the properties. Please see Script Component as a Transformation to understand these properties

SSIS Script Component as Source 3

STEP 4: Within the Input and Outputs tab, Go to Output Columns, and under output columns, we are going add these columns: ID, Name, Country using Add Column button

SSIS Script Component as Source 4

First, we add the Country Column, and then changed the Data type from Integer (default) to string [DT_STR]

SSIS Script Component as Source 5

Similarly, we added the remaining columns. Remember, you can use the Name property to change the Column names as need.

SSIS Script Component as Source 6

Next, we are changing the Output name to Myoutput using the Name property. It is not mandatory to change, and it is up to you

SSIS Script Component as Source 8

STEP 5: 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.

SSIS Script Component as Source 7

Once you click on the Edit Script, it will open the main.cs class file to write the C# code. To send some code, we have to write our custom code inside the CreateNewOutputRows() function

SSIS Script Component as Source 9

STEP 6: Add your custom C# code here. For this example, we declared two string arrays, and then we used the for loop to assign each array element to individual row.

SSIS Script Component as Source 10

Code that we used in the above screenshot is:

C# CODE

public override void CreateNewOutputRows()
 {
   /*
      Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
      For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
   */
   //int[] Identity = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
   
   // Creating String array holding the Country Names 
   string[] CountryNames = new string[] { "India", "USA", "China", "UK", "Canada", 
                                         "Australia", "Japan", "Russia", "South Africa", "Brazil"};
   // Creating String array holding the Names
   string[] CustomerNames = new string[] { "Tutorial", "Gateway", "Yong", "John", 
                                           "Dave", "David", "Xing", "Mike", "Joseph", "Ronaldo"};

   for (int i = 0; i < CountryNames.Length; i++)
   {
      /* Myoutput is the Name that we given in Script component.
         Please provide the name that you see, or assigned in Script Component
      */
      MyoutputBuffer.AddRow();
      MyoutputBuffer.ID = i; // Identity[i];
      MyoutputBuffer.Country = CountryNames[i];
      MyoutputBuffer.Name = CustomerNames[i];
   }
 }

STEP 7: 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 OLEDB Destination

SSIS Script Component as Source 11

STEP 8: Double click on OLE DB Destination will open the OLE DB Destination Editor.

SSIS Script Component as Source 12

STEP 9: Select the OLE DB Connection manager that you already created (if not, create a new one using the New button). Here we are selecting the [SSIS Script Component as Source] table present in the [SSIS Tutorials] Database.

SSIS Script Component as Source 13

STEP 10: Click on the Mappings tab to check whether the source columns mapped to the destination columns.

SSIS Script Component as Source 14

Click OK to finish creating our SSIS Script Component as Source Package.

STEP 11: Right-click on the SSIS Script Component as Source Package in the Solution Explorer, and select Execute Package.

SSIS Script Component as Source 15

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]
GO

SELECT [ID]
      ,[Name]
      ,[Country]
  FROM [SSIS Script Component as Source]

OUTPUT

SSIS Script Component as Source 16

Placed Under: SSIS

  • What is SSIS
  • Install SQL Server Data Tools
  • Learn SSIS in 28 Days
  • Create a SSIS Project
  • Create SSIS Package
  • SSIS Connection Manager
  • OLE DB Connection Manager
  • SSIS ADO Connection Manager
  • ADO.NET Connection Manager
  • SSIS Cache Connection Manager
  • SSIS Excel Connection Manager
  • SSIS File Connection Manager
  • SSIS FTP Connection Manager
  • SSIS SMO Connection Manager
  • Source Assistance in SSIS
  • Flat File Source in SSIS
  • OLE DB Source in SSIS
  • Excel Source in SSIS
  • ADO.NET Source in SSIS
  • SSIS FLAT FILE Destination
  • SSIS OLE DB Destination
  • SSIS ADO.NET Destination
  • SSIS Transformations
  • SSIS Audit Transformation
  • SSIS Aggregate Transformation
  • SSIS Aggregate Advanced Mode
  • SSIS Cache Transformation
  • SSIS Character Map
  • SSIS Conditional Split
  • SSIS Copy Column
  • SSIS Data Conversion
  • SSIS Derived Column
  • SSIS Export Column
  • SSIS Fuzzy Grouping
  • SSIS Fuzzy Lookup
  • SSIS Import Column
  • SSIS Lookup Introduction
  • Lookup – OLE DB Connection
  • SSIS Lookup in Full Cache Mode
  • SSIS Lookup – Case Sensitivity
  • SSIS Merge Transformation
  • SSIS Merge Join Transformation
  • SSIS Merge Join – Left Outer Join
  • SSIS Merge – Right Outer Join
  • SSIS Merge Join – Full Outer Join
  • SSIS Multicast Transformation
  • SSIS OLEDB Command
  • OLEDB Command – Delete Data
  • OLEDB Command-Update Data
  • SSIS Percentage Sampling
  • SSIS Pivot Transformation 2008
  • SSIS Pivot Transformation
  • SSIS Row Count Transformation
  • SSIS Row Sampling
  • Script Component as Source
  • Script Component as Destination
  • SSIS Script as Transformation
  • SSIS Sort Transformation
  • SSIS SCD Type 0
  • SSIS SCD Type 1
  • SSIS SCD Type 2
  • SSIS Term Lookup
  • SSIS Term Extraction Intro
  • Term Extraction – Extract Nouns
  • SSIS Extract Noun Phrases
  • Extract Nouns & Noun Phrases
  • Term Extraction – Exclusion Tab
  • SSIS Unpivot Transformation
  • SSIS Union All Transformation
  • SSIS For Loop Container
  • SSIS ForEach File Enumerator
  • SSIS ForEach SMO Enumerator
  • SSIS ForEach Variable
  • SSIS Foreach NodeList
  • Foreach ADO.NET Schema Rowset Enumerator
  • SSIS Bulk Insert Task
  • SSIS Data Profiling Task
  • Execute T-SQL Statement Task
  • SSIS Execute SQL Task Intro
  • SSIS Execute SQL Task Example
  • Execute SQL Task- Single Rowset
  • Execute SQL Task – Full Row Set
  • SSIS Execute Package Task
  • Execute Packages in SQL Server
  • Execute Packages in File System
  • SSIS Execute Package Project Reference
  • SSIS File System Task
  • SSIS File System Task- Copy Files
  • File System Task-Copy Directory
  • File System Task – Delete Files
  • File System Task – Delete Folder
  • File System Task -Move Directory
  • SSIS File System Task -Move File
  • File System – Move Multiple files
  • File System Task – Rename File
  • File System Task – Set Attributes
  • SSIS FTP TASK
  • SSIS Create Local Directory
  • SSIS Create Remote Directory
  • SSIS FTP Task Send Files
  • SSIS FTP – Send Multiple Files
  • SSIS FTP Task Delete Local Files
  • FTP TASK Delete Local Directory
  • FTP Task Delete Remote files
  • SSIS Delete Remote Directory
  • SSIS FTP Task Receive Files
  • SSIS FTP Receive Multiple Files
  • SSIS Script Task
  • Transfer SQL Server Objects Task
  • Transfer SQL Table Structures
  • Transfer SQL Tables with Data
  • Transfer SQL Stored Procedures
  • Transfer User Defined Functions
  • Transfer SQL Views in SSIS
  • SSIS Web Service Task
  • SSIS XML Task-Validate XML File
  • Transform XML File using XSLT
  • XML Task-XML files Differences
  • Create SSIS Catalog
  • Package Deployment using BIDS
  • Deploy Package Using SQL
  • Deploy using SQL Server Wizard
  • SSIS Breakpoints
  • SSIS Checkpoints
  • SSIS Error Handling
  • SSIS Event Handlers
  • SSIS Transactions
  • SSIS Logging
  • SSIS Parameters
  • SSIS Package Configuration
  • Configure using SQL Server
  • Config using Registry Entry
  • Conf with Environment Variable
  • SSIS XML Configuration File
  • XML Configuration File Part 2
  • SSIS Package Protection Level
  • SSIS Incremental Load
  • Incremental Load Example 2
  • SSIS Remove Double Quotes

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy