Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Archive/Purge History Records using SQL2000

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-15 : 08:28:04
don writes "Need to create a job that archives and purges history records
on a weekly basis.

What is the best solution?

1. New Job? If so, then how?
2. DTS? If so, then how?
3. Other?


thanks

don"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-15 : 08:52:34
Something like this:

INSERT INTO archiveTable
SELECT * FROM myTable WHERE dateColumn < DateAdd(dd, -7, getdate())
DELETE FROM myTable WHERE dateColumn < DateAdd(dd, -7, getdate())


You can then create a new job, add a T-SQL step using the above code, and then set a schedule on it to run once a week. You can do it through Enterprise Manager pretty easily, or use the sp_job... system procedures. There's more info on them in Books Online.

Go to Top of Page
   

- Advertisement -