dbTalk Databases Forums  

DTS or SQL Server programming question

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


Discuss DTS or SQL Server programming question in the microsoft.public.sqlserver.dts forum.



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

Default DTS or SQL Server programming question - 10-20-2006 , 03:56 PM






I'm not sure exactly where this question ought to reside.....

In our production environment, we have 2 sql servers that we alternate
between different days production totals. For instance, on Friday,
Server #1 (the primary one) will load the previous night's production
totals to it for reporting. Server #2 would not run anything then. The
next night, Server #2 would load production totals from Friday night for
reporting, and Server #1 would not do anything. It alternates between
those two servers 6 days a week.

I need to run a job that would run on the first of each month, for the
previous month's totals for a single customer & email the results after
they've been loaded into an excel spreadsheet.

My question is - since we alternate servers, the first of the month
could fall on either server - how can I make this job run 1 time, on the
data on the appropriate server?

I know that Sunday/Monday, Wednesday, and Friday would be on Server #1,
and Tuesday, Thursday & Saturday would be on Server #2.

I'd like to schedule one job to do this and email the report. It'd be
no problem to have separate steps to do that.

I'd like any opinions......

BC


Reply With Quote
  #2  
Old   
Kart
 
Posts: n/a

Default Re: DTS or SQL Server programming question - 10-20-2006 , 04:16 PM






Hi,

Cant you just keep one more table in both these databases that would
have details as to which process ran when? Whichever has the max date
would be the one where the last update took place.

Hope this would work for you.

Blasting Cap wrote:
Quote:
I'm not sure exactly where this question ought to reside.....

In our production environment, we have 2 sql servers that we alternate
between different days production totals. For instance, on Friday,
Server #1 (the primary one) will load the previous night's production
totals to it for reporting. Server #2 would not run anything then. The
next night, Server #2 would load production totals from Friday night for
reporting, and Server #1 would not do anything. It alternates between
those two servers 6 days a week.

I need to run a job that would run on the first of each month, for the
previous month's totals for a single customer & email the results after
they've been loaded into an excel spreadsheet.

My question is - since we alternate servers, the first of the month
could fall on either server - how can I make this job run 1 time, on the
data on the appropriate server?

I know that Sunday/Monday, Wednesday, and Friday would be on Server #1,
and Tuesday, Thursday & Saturday would be on Server #2.

I'd like to schedule one job to do this and email the report. It'd be
no problem to have separate steps to do that.

I'd like any opinions......

BC


Reply With Quote
  #3  
Old   
Hank123
 
Posts: n/a

Default RE: DTS or SQL Server programming question - 10-20-2006 , 04:38 PM



I don't know if this helps but you could use
"select DATENAME(weekday,getdate())"
to find out what the current day of the week it is?

"Blasting Cap" wrote:

Quote:
I'm not sure exactly where this question ought to reside.....

In our production environment, we have 2 sql servers that we alternate
between different days production totals. For instance, on Friday,
Server #1 (the primary one) will load the previous night's production
totals to it for reporting. Server #2 would not run anything then. The
next night, Server #2 would load production totals from Friday night for
reporting, and Server #1 would not do anything. It alternates between
those two servers 6 days a week.

I need to run a job that would run on the first of each month, for the
previous month's totals for a single customer & email the results after
they've been loaded into an excel spreadsheet.

My question is - since we alternate servers, the first of the month
could fall on either server - how can I make this job run 1 time, on the
data on the appropriate server?

I know that Sunday/Monday, Wednesday, and Friday would be on Server #1,
and Tuesday, Thursday & Saturday would be on Server #2.

I'd like to schedule one job to do this and email the report. It'd be
no problem to have separate steps to do that.

I'd like any opinions......

BC



Reply With Quote
  #4  
Old   
SAJJAS
 
Posts: n/a

Default RE: DTS or SQL Server programming question - 10-20-2006 , 07:16 PM



REQUIREMENT: You need to run a job (DTS) as follows,

a) First of the month
b) Run on one server
c) Fetch data for a customer for the whole of last month from the
alternating servers and export to EXCEL.

SOLUTION:

a) Create Linked Servers between the two servers for easy data referencing.
b) Create a Execute SQL Task to fetch data from both of the tables using the
following query
SELECT * FROM [SERVER1].[DBO].[TABLENAME] WHERE [DATEFIELD]
IN('StartofMonth', 'EndOfMonth')
UNION
SELECT * FROM [SERVER2].[DBO].[TABLENAME] WHERE [DATEFIELD]
IN('StartofMonth', 'EndOfMonth')
c) Create an EXCEL Connection
d) Use transform data task to export the SQL results to EXCEL.

Hope this helps.

--
SAJJAS


"Blasting Cap" wrote:

Quote:
I'm not sure exactly where this question ought to reside.....

In our production environment, we have 2 sql servers that we alternate
between different days production totals. For instance, on Friday,
Server #1 (the primary one) will load the previous night's production
totals to it for reporting. Server #2 would not run anything then. The
next night, Server #2 would load production totals from Friday night for
reporting, and Server #1 would not do anything. It alternates between
those two servers 6 days a week.

I need to run a job that would run on the first of each month, for the
previous month's totals for a single customer & email the results after
they've been loaded into an excel spreadsheet.

My question is - since we alternate servers, the first of the month
could fall on either server - how can I make this job run 1 time, on the
data on the appropriate server?

I know that Sunday/Monday, Wednesday, and Friday would be on Server #1,
and Tuesday, Thursday & Saturday would be on Server #2.

I'd like to schedule one job to do this and email the report. It'd be
no problem to have separate steps to do that.

I'd like any opinions......

BC



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.