Total Pageviews

Thursday, August 16, 2012

Displaying variable's value using script task in SSIS

When we run Execute SQL task we need to know the value given by the executed query. We can use Script task for the same. Please follow the steps mentioned below:
Step1: Create the package with 2 variables(one as parameter for Execute SQL Task and another  for result set).
Step2: Select Execute SQL Task from Tool Box and write the query as per the requirement.

Here, in SQL Statement, we keep the question mark('?') to accept the value of parameter '@day'assigned to it.Then this value will be given to the other defined variable day2, in Result set.




Step3: Select Script Task from tool box. And open the script task editor.




Step4: Here we select the second variable User::Day2. 
Step5: Open Edit Script and edit the code in Main() body.




Step6: Write the following code in the Main() body:

MessageBox.show(DTS.Variables["Variable_Name"].Value.ToString());


Step7: Click OK  and execute the package to see the value of User::@day which was passed to User::@day2.


No comments:

Post a Comment