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

Repeating code over time period Expand / Collapse
Author
Message
Posted Wednesday, March 6, 2013 8:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 15, 2013 12:27 AM
Points: 6, Visits: 7
Hi Guys,

I have a code snippet to run every month and have to take a union of current data and previous 11 months data and put in excel to prepare a report. I have to create a table with current month suffix and there are changes to be made to date variables.

Any suggestion how I can avoid making changes to the code and generate reports based on the current month,(it should automatically create a table based on the current month and take a union with the previous 12 months data only)?

Your help is appreciated!

Regards,
Prasanna
Post #1427460
Posted Wednesday, March 6, 2013 9:30 AM


SSC-Dedicated

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

Group: Administrators
Last Login: Today @ 12:38 AM
Points: 33,267, Visits: 15,436
Use SSIS to build a package. Base a query on dateadd to get the previous 11 months in your query.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1427492
Posted Sunday, March 10, 2013 8:23 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, September 1, 2014 11:26 AM
Points: 647, Visits: 762
I agree with steve,

SSIS would be your best bet if you have the knowledge to use it.

Alternative if you don't have SSIS knowledge you can use a SP on the database level and SSRS as frontend witch can also be sheduled to run on certain timestamps and provide the data as needed.

Wkr,
Eddy
Post #1428984
Posted Sunday, March 10, 2013 6:30 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Sunday, September 29, 2013 1:24 AM
Points: 429, Visits: 1,721
A partitioned view might be what you're looking for. Take a look at these links:

Using Partitioned Views
Modifying Data in Partitioned Views

 
Post #1429044
Posted Monday, March 11, 2013 11:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 12, 2014 4:31 AM
Points: 1, Visits: 34
Have you considered just exectuing the query in Excel to begin with? You can create formulas in cells adjacent to the data set for formatting or other conditioning. I do this for several reports to get the 'Week Of' as the Monday date of that week and one for 'Day of Week' as well. These formula based values work very nicely in pivot tables and charts. Simply refresh the table and pivot data. from within the Excel report.
Post #1429413
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse