Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS lproblem

Status
Not open for further replies.

rsbutterfly16

IS-IT--Management
Apr 19, 2007
53
US
hi guys , i have a dts that i run manually everyday, in which drops the table and then create it and makes a copy of it from another database. But i need to make a change in the dts to first insert a timestamp of when the data was inserted and that if the date is the same as the day running it again then to append the rows. How should i do this?
 
a few ideas in random order:

let the table exist permanently, not dropping each time
add col LastChanged smalldatetime

save the current system-time into a date variable (getDate)

If # if rows in table > 0
select top 1 (LastChanged) from table

If LastChanged date is not = current date (you can use the Date Diff functions to determine # of days between 2 dates)
use truncate table to clear all rows


Insert your new records, using the current date var value to populate the lastChanged column.

Sorry I don't have time to provide all the code. Maybe this psuedo-code will help. Books On Line is a good place to start.

There are several ways to accomplish what you want to do....

John


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top