SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Urgent help - foreach loop container


Urgent help - foreach loop container

Author
Message
whly
whly
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 107
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.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)

Group: General Forum Members
Points: 204432 Visits: 41950
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
whly
whly
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 107
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?
whly
whly
Grasshopper
Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)Grasshopper (13 reputation)

Group: General Forum Members
Points: 13 Visits: 107
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.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)SSC Guru (204K reputation)

Group: General Forum Members
Points: 204432 Visits: 41950
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search