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

Running package in a loop Expand / Collapse
Author
Message
Posted Wednesday, February 20, 2013 3:54 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, June 17, 2013 11:37 AM
Points: 220, Visits: 543
I have a pacakge that pulls the data from the table for a month. It runs on the first of the month and it pulls the previous month of data.

Requirement is to generate files for June 2011 to present but broken them weekly based on the transaction date. How can I run it in a loop per week for that time period?
Post #1422341
Posted Wednesday, February 20, 2013 4:53 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 1,337, Visits: 4,025
[sarcasm]Simply set the date bucket parameter to weekly and the range filter from June 2011 to today.[/sarcasm]

Sorry, feeling a bit

Truly...

Create a dates table (with weeks in it)
Add a data flow to grab the weeks from the dates table for the required range and feed that into a package variable (recordset destination)
use a foreach loop to loop through the weeks in the variable
feed the start and end dates from the week into your extract routine (where clause)
output to file (use expression to build file name using week number from loop)


If I have assumed too much knowledge and Google doesn't help , then ask questions by all means


MM




Post #1422357
Posted Wednesday, February 20, 2013 10:04 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, June 17, 2013 11:37 AM
Points: 220, Visits: 543
Thanks. Another question. I have a for each container that reads dates from the table. Inside the container, I've execut SQL task. I did the parameter mapping and seems like I can't access date variable in execute SQL task. Getting syntax error or access violation error. Any idea?
Post #1422393
Posted Thursday, February 21, 2013 2:09 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 12:19 AM
Points: 4,328, Visits: 9,666
mister.magoo (2/20/2013)
[sarcasm]Simply set the date bucket parameter to weekly and the range filter from June 2011 to today.[/sarcasm]

Sorry, feeling a bit

Truly...

Create a dates table (with weeks in it)
Add a data flow to grab the weeks from the dates table for the required range and feed that into a package variable (recordset destination)
use a foreach loop to loop through the weeks in the variable
feed the start and end dates from the week into your extract routine (where clause)
output to file (use expression to build file name using week number from loop)


If I have assumed too much knowledge and Google doesn't help , then ask questions by all means


Alternatively, add a Conditional Split in the data flow and split the data into four streams - to four separate files.


____________________________________________________________________________________________

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

http://www.sqlservercentral.com/articles/Best+Practices/61537/

If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
Post #1422443
Posted Thursday, February 21, 2013 2:16 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 1,337, Visits: 4,025
Phil Parkin (2/21/2013)

Alternatively, add a Conditional Split in the data flow and split the data into four streams - to four separate files.


I like this idea, but only if every month has four weeks in it


MM




Post #1422446
Posted Thursday, February 21, 2013 2:19 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 1,337, Visits: 4,025
SQL_Surfer (2/20/2013)
Thanks. Another question. I have a for each container that reads dates from the table. Inside the container, I've execut SQL task. I did the parameter mapping and seems like I can't access date variable in execute SQL task. Getting syntax error or access violation error. Any idea?


Can you explain how you are trying to use the variable?

I was thinking that your existing routine would have a date range that it pulled and you would be replacing an existing set of variables with those from the loop (or calling your existing package from a new one and passing in the variables values to existing variables in the original package)...

Are you calling a SP or just using a query ?

More info please?


MM




Post #1422448
Posted Thursday, February 21, 2013 2:20 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 12:19 AM
Points: 4,328, Visits: 9,666
mister.magoo (2/21/2013)
Phil Parkin (2/21/2013)

Alternatively, add a Conditional Split in the data flow and split the data into four streams - to four separate files.


I like this idea, but only if every month has four weeks in it


Well, I did give that some thought.

And there has to be a prior step to set up variables containing the 'break dates' for the month too.

But thought it worth a mention nonetheless.


____________________________________________________________________________________________

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

http://www.sqlservercentral.com/articles/Best+Practices/61537/

If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
Post #1422449
Posted Thursday, February 21, 2013 7:20 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, June 17, 2013 11:37 AM
Points: 220, Visits: 543
I have a table which stores date per week. I am passing those dates to my inline statement (in execute sql statement).
Post #1422575
Posted Thursday, February 21, 2013 7:33 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 1,337, Visits: 4,025
SQL_Surfer (2/21/2013)
I have a table which stores date per week. I am passing those dates to my inline statement (in execute sql statement).


How? Show us please

What error are you getting? Show us the exact error please


MM




Post #1422584
Posted Thursday, February 21, 2013 1:31 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, June 17, 2013 11:37 AM
Points: 220, Visits: 543
It worked after converted inline statments to stord proc. thanks for your help.
Post #1422778
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse