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
 Transact-SQL (2000)
 Moving records to another table when one month old

Author  Topic 

SQLISCOOL
Starting Member

5 Posts

Posted - 2005-04-26 : 07:25:45
Hi, this may sound simple but I am more of a VB guy than a database kind of person. Basically I have a program that allows the user to enter records into a SQL Server database using:

INSERT W_TBL_JOBS (RequestedBy, Notes, ReceiveDate, ReceiveTime, RequestedDate, RequestedTime, mattercode, clientname, CompletedStatus) VALUES (@txtWorkReqBy, @txtExt, @cboFloor1, @lblNotes, @RecDate, @RecTime, @ReqDate, @ReqTime, @mattercode, @client, @compStatus

Now what I want to do is when a record in my table becomes more than one month old (i.e. ReceiveDate >= today's date) then move it to a table called tbl_ArchivedRecords.

I'm not sure what is the best way to do this. As I understand, a trigger only works when users input data but not when records become old themselves. What kind of method should I be using to automatically check which reocrds in my table are older than a month and then move them?

Any help appreciated
Thanks

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2005-04-26 : 07:42:22
You would use a "scheduled job", these will run without any user input. You can write a simple stored procedure to move all your old records to an archive table, then create a new job which calls that SP. You can then schedule this job to run at periodic intervals (e.g. once a week). If you have SQL Server installed, lookup "Jobs" in the Books Online, there is a lot of info on creating and scheduling jobs.

OS
Go to Top of Page
   

- Advertisement -