OLE DB Command Transformation in SSIS is used to run the SQL Statements like INSERT, UPDATE and DELETE Statements in the Data Flow. Please refer Delete Data Using OLEDB Command Transformation article to understand How to delete data using OLE DB Command Transformation and Update Data using OLEDB Command Transformation article to understand the Update operations.
NOTE: OLE DB Command Transformation in SSIS reads one row at a time from the Data flow and apply the SQL statement on that row. So, the performance will be poor if the number of rows increases. For example, to Update 5 records OLE DB Command Transformation will run 5 times.
Insert Data Using OLE DB Command Transformation in SSIS Example
In this example we will show you, How to insert Data into the destination table using OLE DB Command Transformation. Before we start designing the SSIS Package let us see the Destination Table in [SSIS Tutorials] Database
Drag and drop the Data Flow Task from toolbox to control flow region and rename it as Inserting Data using OLE DB Command Transformation in SSIS 2014.
Double click on it and it will open the data flow tab.
Drag and drop OLE DB Source and OLE DB Command transformation from toolbox to data flow region.
Within the data flow region, Double click on OLE DB source will open the connection manager settings and allows us to select the required table.
The SQL Command we used in the above screenshot is
SELECT [ProductKey] ,[EnglishProductName] ,[StandardCost] ,[Color] ,[ListPrice] ,[DealerPrice] ,[EnglishDescription] FROM [AdventureWorksDW2014].[dbo].[DimProducts]
Click on columns tab to verify the columns. In this tab we can uncheck the unwanted columns also.
Drag the OLE DB Source Output arrow on to the OLE DB Command Transformation to perform transformations on the source data.
STEP 5: Double click on the OLE DB Command Transformation will open the Advanced Editor for OLE DB Command to configure it.
Within the Connection Managers tab we are selecting the already created OLE DB Connection from the list as shown below. Please refer the OLE DB Connection Manager in SSIS article to understand the configuration setting of the connection manager.
Within the Component Properties we have to write the SQL Statement we have to perform. Please select the SqlCommand property and click on the browse button (… button)
Once you click on the browse button, a String Value Editor window will be opened to write the SQL Statement. In this example, we are inserting the values into the products table.
SQL Statement we used in the above screenshot is
INSERT INTO [SSIS Tutorials].[dbo].[Products] ([EnglishProductName] ,[StandardCost] ,[Color] ,[ListPrice] ,[DealerPrice] ,[EnglishDescription]) VALUES (?, ?, ?, ?, ?, ?)
Within the Column Mapping we have to assign the appropriate column name to the parameters.
From the above screenshot you can observe that, Param_0 represents first question mark and param_5 represents fifth question mark.
Lets assign the appropriate column names to the parameters.
Click OK to finish configuring the Inserting Data Using OLE DB Command Transformation In SSIS 2014 package. Let us Run the package
Let us open the SQL Server Management Studio and check the result
Thank You for Visiting Our Blog