dbTalk Databases Forums  

Running parts of sql jobs depending on date

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Running parts of sql jobs depending on date in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Blasting Cap
 
Posts: n/a

Default Running parts of sql jobs depending on date - 11-09-2006 , 10:28 AM






I have to write some sql that has to create a table from which a report
runs that spans over the end of this year.

It's code to build a table that a sales program report is generated
from. The program itself runs until the end of January.

From now thru January 2, orders in the program count. On January 3, I
get a new table - the one I had been using gets changed to a previous
year table, and the new one is the current year table. Also on that
day, instead of orders counting (in the previous year) it goes to
shipments. Orders count in the new (current year) table.

The best way I can come up with to do this is to put in some code in the
table build that builds it one day if getdate() is >= 01/03/2007, and
another way if it's not.

Is there a better way to do something like this, perhaps thru DTS?

What I had in mind is to do something like this:

if getdate() <= '01/02/2007'
begin

several passes at building the table



end -- if getdate <= 01/02/2007



if getdate() >= '01/03/2007'
begin

several passes at building the table



end -- if getdate >= 01/03/2007

Reply With Quote
  #2  
Old   
Arnie Rowland
 
Posts: n/a

Default Re: Running parts of sql jobs depending on date - 11-09-2006 , 11:36 AM






It's not unusual to have Jobs that execute ONLY on Jan 1st. Archive data,
create tables, partition tables, etc.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


"Blasting Cap" <goober (AT) christian (DOT) net> wrote

Quote:
I have to write some sql that has to create a table from which a report
runs that spans over the end of this year.

It's code to build a table that a sales program report is generated from.
The program itself runs until the end of January.

From now thru January 2, orders in the program count. On January 3, I get
a new table - the one I had been using gets changed to a previous year
table, and the new one is the current year table. Also on that day,
instead of orders counting (in the previous year) it goes to shipments.
Orders count in the new (current year) table.

The best way I can come up with to do this is to put in some code in the
table build that builds it one day if getdate() is >= 01/03/2007, and
another way if it's not.

Is there a better way to do something like this, perhaps thru DTS?

What I had in mind is to do something like this:

if getdate() <= '01/02/2007'
begin

several passes at building the table



end -- if getdate <= 01/02/2007



if getdate() >= '01/03/2007'
begin

several passes at building the table



end -- if getdate >= 01/03/2007



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.