Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

For each loop container where  data comes from multiple columns in select from a SQL table

Posted on 2014-11-10
2
Medium Priority
?
227 Views
Last Modified: 2014-11-11
I need to create an SSIS package that will create  files  where the file name contains the Date and time of all rows  that are selected from a SQL table.  I gather that I need to use a foreach loop container, and I Have three variables that hold Dte:  '1/2/2014' which is the date from the input table,  Hr:  15 which contains the hour of the day and Portion: 1 or 2 which designates if the activity occurred in the first half hour (1) or the second half hour.  
Do I need to generate a for each loop that for each Date then within that for each loop the hour of the day, then a third for each loop that designates the half hour or can I do I all in one For each loop?  

Can someone give me an idea of how to proceed?

Thanks
0
Comment
Question by:LenTompkins
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 total points
ID: 40433107
Don't have it imported from an SQL table - import it from an SQL view which is based on the table.

In the view, add a separate field which combines the three fields into one date, similar to the filename you want to create. It should be a SELECT DISTINCT query, so each filename only comes up.

Then use that view as the source for your loop - see the article http://redmondmag.com/articles/2009/11/02/loop-thru-rows.aspx for more details.
0
 

Author Closing Comment

by:LenTompkins
ID: 40435038
I got it to work.  Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question