Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««1234»»»

SSIS - ForEach From Variable Enumerator Expand / Collapse
Author
Message
Posted Tuesday, December 22, 2009 9:37 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11, Visits: 46
That worked for me. I was able to figure out where I'm doing wrong.

Thanks,
Prasad
Post #838009
Posted Tuesday, December 22, 2009 10:16 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, April 17, 2014 7:37 AM
Points: 860, Visits: 2,323
Firstly I wouldnt use a Script task they ar quite slow and can have problems on 64bit machines if they arnt precompiled.

I would use an Execute SQL task to get the data set and assign it to a Variable of Type Object.

You can then use the For Each ADO enumerator to parse the Each element of Object Variable into a New Variable using the Variable Mapping section of the Loop Column 1 in the record set = Index 0 on the mappnig (Column 2= 1, and so on).



_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #838060
Posted Tuesday, December 22, 2009 11:37 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, April 11, 2014 7:30 AM
Points: 346, Visits: 518

^^ Correct.

Also you wouldn't want to hardcode something like database names in the script task -
as new databases may be added or dropped..



--
Sabya
Post #838115
Posted Tuesday, December 22, 2009 8:14 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:52 PM
Points: 36,016, Visits: 30,304
Heh... I probably wouldn't use SSIS for such a thing. I damned sure wouldn't use a script for this. T-SQL would do the job just fine.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #838343
Posted Wednesday, December 23, 2009 12:05 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 10:56 AM
Points: 4,832, Visits: 11,200
Jeff Moden (12/22/2009)
Heh... I probably wouldn't use SSIS for such a thing. I damned sure wouldn't use a script for this. T-SQL would do the job just fine.


So ... what would you use SSIS for Jeff?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #838387
Posted Wednesday, December 23, 2009 7:31 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11, Visits: 46
Jeff Moden (12/22/2009)
Heh... I probably wouldn't use SSIS for such a thing. I damned sure wouldn't use a script for this. T-SQL would do the job just fine.


Hi Jeff,

I'm new to SSIS and I'm trying to see how I can use the foreach loop container in big scheme of things. This is a part of the package and package does have multiple data flow tasks in it besides the foreach loop container.

Thanks,
Prasad
Post #838509
Posted Wednesday, December 23, 2009 7:35 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 10, 2011 1:45 PM
Points: 11, Visits: 46
sabyasm (12/22/2009)

^^ Correct.

Also you wouldn't want to hardcode something like database names in the script task -
as new databases may be added or dropped..



Hi Sabyasm,

Good point. I'm not retreving and hardcoding the database names. I'm just gettng the names of the feeds we do run at work and those are configured by our team

Thanks,
Prasad
Post #838511
Posted Tuesday, December 21, 2010 7:32 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 25, 2011 2:34 AM
Points: 5, Visits: 22
- Set up a variable to hold the Array. This must be a System.Object type variable.
- Set up a variable to hold the current array value. The must be a String.
- Set the array up like this;

Dim sourceTabs() As String
sourceTabs = "Sheet1$,Sheet2$".Split(",")

- Set the loop up using the above variables
- Voila!

(The example above was used to iterate through a fixed list of Excel tabs which were then used as data sources.)

The crucial part was to set up the object as an Array, rather than an ArrayList.

Stu
Post #1037719
Posted Wednesday, December 22, 2010 9:35 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 1:52 PM
Points: 36,016, Visits: 30,304
Phil Parkin (12/23/2009)
Jeff Moden (12/22/2009)
Heh... I probably wouldn't use SSIS for such a thing. I damned sure wouldn't use a script for this. T-SQL would do the job just fine.


So ... what would you use SSIS for Jeff?


Heh... (counting my lucky stars as I speak)... "nothing" is all I can come up with, so far.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1038358
Posted Wednesday, December 22, 2010 3:56 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 5:43 PM
Points: 37, Visits: 364
Use ADO instead.
Post #1038540
« Prev Topic | Next Topic »

Add to briefcase ««1234»»»

Permissions Expand / Collapse