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.
| 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 recordson a weekly basis.What is the best solution?1. New Job? If so, then how?2. DTS? If so, then how?3. Other?thanksdon" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-07-15 : 08:52:34
|
| Something like this:INSERT INTO archiveTableSELECT * 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. |
 |
|
|
|
|
|