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 |
|
aturner
Starting Member
29 Posts |
Posted - 2004-08-19 : 09:22:19
|
| I currently have a table that store topics of interest that individuals can view in a seven (7) day period. The table consists of the following fields: TopicID, DateCreated, Subject, Discussion, Review, DateModified. How can I construct a stored procedure that will purge topics that are seven days old and move them to an archive table with the same data type, allowing new topics to be entered. The archive table would allow individuals to review previous topics when needed. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-19 : 09:28:55
|
| will this do?insert into ArchiveTable (TopicID, DateCreated, Subject, Discussion, Review, DateModified)select TopicID, DateCreated, Subject, Discussion, Review, DateModifiedfrom MyTablewhere DateCreated >= DateAdd(d, -7, getDate())delete from from MyTablewhere DateCreated >= DateAdd(d, -7, getDate())Go with the flow & have fun! Else fight the flow :) |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-08-19 : 09:34:38
|
| Another design option might be to create an archive flag in the existing table. Then just update the flag. |
 |
|
|
|
|
|
|
|