Wednesday, April 24, 2019

SSIS - How To Pass input parameter in Execute SQL Task

This blog will explain how to create a variable and how to pass it as input parameter in Execute SQL Task

Create Variable in SSIS Package.

We have a SQL task and this task will update project schedule date based on input date

SSIS SQL Task 

SQL Query:

Update Project SET ScheduleDate = ?

or

sp_updateScheduleDate ?

In above SQL query, we need to pass input parameter for schedule date, for this first we need to create a variable

1.    Open the Execute SQL task Editor -

Right Click on SQL Task à Select Edit à Open the Execute SQL task Editor


SSIS SQL Task Editor



SSIS SQL Task Editor


2.    Select Parameter Mappings

SSIS SQL Task Editor Parameter Mapping


3.    Click on Add button and Add Variable popup window will be opened and enter below fields


SSIS SQL Task Add Variable


·         Container   -  Specify Scope of variable, by default SSIS package name – eg Update
·         Name - Enter variable Name eg – ScheduleDate.
·         Namespace – Enter Namespace
·         Value Type – Select Data Type for variable (eg DateTime) 

SSIS SQL Task Add Variable Value Type

·         Value (by default value) – Today Date – 12/12/2019


After entered above fields and click on OK button


Maps variable as input parameter in SQL Task:

Maps the created variable ScheduleDate (User::ScheduleDate) as input parameter for SQL task and in SQL script, we have only one input parameter symbol ‘?’  So give parameter name as 0, and define parameter size 10 for Date Field

SSIS SQL Task Editor Parameter Mapping 

If you have more than one input parameter, then give parameter name as 0, 1, and 2.

SQL Query:

Update Project SET ScheduleDate = ?, ProjectName = ?

SSIS SQL Task Editor Parameter Mapping



3 comments:

Anonymous said...

How is this C#?

Rajeev Tiwari said...
This comment has been removed by the author.
James Zicrov said...

Thank you so much for providing information about SSIS and other such aspects of IT which helps in solving many complex IT problems, Not sure if you are interested in 3rd party product but here is the solution.
Link here" SSIS Upsert

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...