Scenario:
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.
Solution:
Here is quick demo that will show you step by step approach to read Object Type variable in Script Task.
Step 1:
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
Union All
Select 2 as ID, 'Raza' AS Name
Step 2:
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
using System.Data.OleDb;
OleDbDataAdapter A = new OleDbDataAdapter();
System.Data.DataTable dt = new System.Data.DataTable();
A.Fill(dt, Dts.Variables["User::VarObject"].Value);
// TODO: Add your code here
foreach (DataRow row in dt.Rows)
{
string ID;
string Name;
object[] array=row.ItemArray;
ID = array[0].ToString();
Name = array[1].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);
Final Output:
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.
Demasiado bueno el post... gracias
ReplyDeleteThank you for delivering the great blog and keep doing...
ReplyDeleteLinux Training in Chennai
Linux Course in Chennai
Advanced Excel Training in Chennai
Oracle Training in Chennai
Job Openings in Chennai
Unix Training in Chennai
Tableau Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Pega Training in Chennai
Spark Training in Chennai
Thank you so much for providing a good and descriptive post about SSIS.I genuinely feel this is the best way in which one can actually get to understand some crucial technicalities of SSIS.
ReplyDeleteSSIS Postgresql Write
This is an awesome post. Really very informative and creative contents. oracle training in chennai
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHI I am getting below error ,Not sure whats happening
ReplyDeleteobject is not an adodb.recordset or an adodb.record site:
Mua vé tại đại lý vé máy bay Aivivu, tham khảo
ReplyDeletegiá vé máy bay đi Mỹ khứ hồi
vé máy bay qn đi sg
vé máy bay đi hà nội tháng 6
vé đi nha trang giá rẻ
ve may bay di Hue gia re
thuê xe ô tô đi sân bay nội bài
combo du lịch đà nẵng tháng 7
If Oracle is your dream job, then we, Infycle, are with you to make your dream into reality. Infycle Technologies offers the best Oracle Training in Chennai, which offers various programs in Oracle such as Oracle PLSQL, Oracle DBA, etc., in the 200% hands-on practical training with specialized trainers in the field. Also, the mock interviews will be arranged for the candidates to face the interviews without any fear, and 100% placement assurance will be given here. To have the words above real, call 7502633633 to Infycle Technologies and grab a free demo to know moreBest Oracle Training in Chennai | Infycle Technologies
ReplyDeleteInfycle Technologies, the best software training institute in Chennai offers the leading Python course in Chennai for tech professionals, freshers, and students at the best offers. In addition to the Python course, other in-demand courses such as Data Science, Cyber Security, Selenium, Oracle, Java, Power BI, Digital Marketing also will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.
ReplyDeleteThis is a very interesting post. Thank you for posting a lot of interesting post.
ReplyDeleteทางเข้าเล่น igoal
Board of Secondary Education, Andhra Pradesh, (BSEAP) Going to Conducts 6th, 7th, 8th, 9th, 10th Class Examination 2023, Every year more than 16 Lakhs of Students Appeared in this Exam, AP 6th, 7th, 8th, 9th, 10th Class Exam Dates Expected to be Announce Month of Soon. AP 8th Question Paper 2023 Students Alert this Time High School & Primary Schools Study Materials and Plans a Strategic Study Routine to Score well in the Exam.
ReplyDeleteI have been working on a project for the last day and all of the other examples I have been able to find online have not been able to lay it out in a way helpful to me. Your example of "SSIS - How To Read Object Type Variable In Script Task [Script Task SSIS]" gave me exactly what I needed, and wanted to thank you for that!!!
ReplyDeleteЭто очень важная информация.
ReplyDelete