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

Urgent help - foreach loop container Expand / Collapse
Author
Message
Posted Thursday, May 16, 2013 5:21 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, September 7, 2014 1:00 AM
Points: 11, Visits: 92
My case is very simple but I can't resolve the issue using SQL Server 2008R2 BIDS.

I need to select out a list of managers from a table. Then use foreach loop container to loop through this list and feed to a stored procedure which takes 3 parameters (manager_name, date, interval) to generate a table, say saleperson's performance records under each manager.

I used execute SQL task to get the list of managers first. The variables are: FullResultSet (data type is object), RepDate (Date), ManagerID (nvarchar). I tried both single and full result set. None worked.

Next is the foreach loop. Use ADO enumerator, FullResultSet as source variable. Variable mapping both RepDate and ManagerID (with the correct order).

Inside the container, I use execute SQL task to execute the stored procedure as myStoreProcedure ?,?,?. Parameters mapped as RepDate, ManagerID and Interval (this is in variable list with a default value).

Issue: The foreach container looped the right number of times. However, the stored procedure never got executed. I didn't get any error message. So I don't know what went wrong? The project is due first thing tomorrow morning. If anybody could help, I'd much appreciated.
Post #1453814
Posted Thursday, May 16, 2013 9:44 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 10:28 PM
Points: 35,215, Visits: 31,666
It sounds to me like you're using the wrong tool.

Are you using an "Parent/Child" table to drive all of this?


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

(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 #1453831
Posted Thursday, May 16, 2013 10:54 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, September 7, 2014 1:00 AM
Points: 11, Visits: 92
Well, these tables are in Data warehouse. They are not really linked via foreign keys.

Thanks for your reply. What else would you recommend me to use?
Post #1453845
Posted Thursday, May 16, 2013 11:03 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, September 7, 2014 1:00 AM
Points: 11, Visits: 92
My case is almost exactly like this one:
http://www.sqlservercentral.com/Forums/Topic631921-148-1.aspx

Wish I have a way to know how this person resolve the issue.
Post #1453846
Posted Friday, May 17, 2013 5:50 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 10:28 PM
Points: 35,215, Visits: 31,666
whly (5/16/2013)
Well, these tables are in Data warehouse. They are not really linked via foreign keys.

Thanks for your reply. What else would you recommend me to use?


Understood. It sounded like you had a hierarchy going on and wanted to know what type because there are some pretty awesome solutions to report on sales for every node and all levels under each node for hierarchical data that's based on a parent/child relationship.

You say you execute an SQL Task to get the managers first. Any chance of you posting that to see if I can help? Will likely need other information, as well, but that will be good as a starting point.


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

(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 #1454215
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse