- C# Scripts
- DWH INTERVIEW QUESTIONS
- MS Dynamics AX 2012 R2 Video Tutorial
- Project / Work Support
- SQL SERVER DBA INTERVIEW QUESTIONS
- SQL SERVER DBA Video Tutorial
- SQL Server / TSQL Tutorial
- SQL Server 2016
- SQL Server Scripts
- SSIS INTERVIEW QUESTIONS
- SSIS Video Tutorial
- SSRS INTERVIEW QUESTIONS
- SSRS Video Tutorial
- TSQL INTERVIEW QUESTIONS
- Team Foundation Server 2013 Video Tutorial
- Team Foundation Server 2015 Video Tutorial
- Windows 10
- Windows Server 2012 R2 Installation Videos
SSIS - How To Read Object Type Variable In Script Task [Script Task SSIS]
It is frequently asked question, I can read object type variable by using For-each Loop in SSIS but How can I read the object type variable in Script Task.
Here is quick demo that will show you step by step approach to read Object Type variable in Script Task.
Create connect to your SQL Server and then use Query in Execute SQL Task as given below and save the result set to VarObject Variable that is object type variable.
Select 1 as ID, 'AAMIR' AS Name
Select 2 as ID, 'Raza' AS Name
Configure Script Task as shown in snapshots for your SSIS Package
Select the Script Language and Variable you need to use in Script Task
Add the Code as shown in snapshot to your Script task
Code that you see in snapshot added by me in Script task
OleDbDataAdapter A = new OleDbDataAdapter();
System.Data.DataTable dt = new System.Data.DataTable();
// TODO: Add your code here
foreach (DataRow row in dt.Rows)
ID = array.ToString();
Name = array.ToString();
// I Declare both variables ID And Name as String, So I can show in Messagebox. You can Declare ID as INT and set the value and use
//However you want to use.
MessageBox.Show("ID Value="+ ID +" AND Name Value=" + Name);
Run your SSIS Package, It is going to Run Execute SQL Task in which it will load the Result Set to VarObject Variable and then inside Script task we are using VarObject variable to read values from and displaying them.