Question.
I'm creating a DTS job to pull data from one table and combine totals based on a combined key. This DTS will be copying this information to a new table in a different DB. I am trying to figure out if there is a good way to only pull records that haven't been copied over to the new table or if I should just do a simple Select statement in my job and have it drop & recreate the destination table.
Table contains:
Bill_ID (primary key)
Cust_ID
Trace_ID (Both Cust_id & Trace_ID are combined key)
Amt
There can be multiple records with the same Cust_ID and Trace_ID and I'm summing all the amounts with the same Cust_ID and Trace_ID.
Right now, my query is written similar to
Which I can use with an Append to Destination Table type of DTS job, but what I think is going to happen is that it will append everything in the source table several times over so that I end up after the second run of the job 2 copies of every record except the new ones.
Since the DTS job will be running frequently during the day, it's not something I can edit regularly to put in a new date or datetime to check against. So my two options are to Drop & ReCreate the Destination Database every time or find a way to have the query check in the new DB for existing records.
Can anyone give me any recommendations as to which option I should go for and why the other option would be bad?
Thanks!
Catadmin - MCDBA, MCSA
Remember, "Work" is a four letter word. And you know what your mother told you about using four letter words!
I'm creating a DTS job to pull data from one table and combine totals based on a combined key. This DTS will be copying this information to a new table in a different DB. I am trying to figure out if there is a good way to only pull records that haven't been copied over to the new table or if I should just do a simple Select statement in my job and have it drop & recreate the destination table.
Table contains:
Bill_ID (primary key)
Cust_ID
Trace_ID (Both Cust_id & Trace_ID are combined key)
Amt
There can be multiple records with the same Cust_ID and Trace_ID and I'm summing all the amounts with the same Cust_ID and Trace_ID.
Right now, my query is written similar to
Code:
Insert Newtable Bill_id, Cust_id, Trace_id, Sum(Amt) as Total
from OldTable join CustomerTable on
OldTable.Cust_ID = CustomerTable.Cust_ID
where Trace_ID in (Select Trace_ID from Oldtable)
and Cust_ID in (Select Cust_ID from Oldtable)
group by Cust_ID, Trace_ID, Bill_ID
Which I can use with an Append to Destination Table type of DTS job, but what I think is going to happen is that it will append everything in the source table several times over so that I end up after the second run of the job 2 copies of every record except the new ones.
Since the DTS job will be running frequently during the day, it's not something I can edit regularly to put in a new date or datetime to check against. So my two options are to Drop & ReCreate the Destination Database every time or find a way to have the query check in the new DB for existing records.
Can anyone give me any recommendations as to which option I should go for and why the other option would be bad?
Thanks!
Catadmin - MCDBA, MCSA
Remember, "Work" is a four letter word. And you know what your mother told you about using four letter words!