Wednesday, April 24, 2019

SSIS - Set variable in SQL task with Single Row and Full result set

In my recent blog SSIS - How To Pass input parameter in Execute SQL Task explained how to pass input parameter in SQL task and this blog we will discuss about to set variable value in SQL task so that in later flow, we can use this variable value and we will also discuss how to map the list of returns value to variables

Here is a SQL Task – Get Project Code based on input project ID parameter.

SSIS SQL Task


SSIS SQL Task Editor


As we see, this SQL task takes ProjectID as input parameter and it always returns single project record.

SSIS_SQL_Task_Variable_InputParameter_Mapping


If result set = “Single Row”, we can maps the result set value to variables like ‘ProjectCode and ProjectName’

SSSI_SQL_Task_Single_Row_ResultSet

These variable we can use in further data flow (load project history data based on project code)

Here is OLD DB Source , we can see its pulling history records based project code

SSIS_OLEDB_SQL_Command_Paramter

And ProjectCode value is being set by input parameter variable

SSIS_Set_Query_Parameter

No comments:

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...