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)
 What trigger to use

Author  Topic 

ASPSQLVB
Starting Member

46 Posts

Posted - 2006-12-30 : 10:28:40
Gang,

In Table 1 (relational database), I have a date that will expire. When it expires I would like to take certain data from the relational databse and insert that data into a table thats all by itself. After this action I would like to delete all the data in the relational database.

So, when the date has reached its expiration, I would like the above to occur.
What trigger would be used for something like this ?

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-12-30 : 17:57:11
You can't use a trigger - a trigger runs when you modify data (insert, update or delete) and nothing is being modified in this case. What you need to do is regularly run a job to check for records with expired dates.

I'd recommend creating a stored procedure to do all the work, then create a job and schedule the job to run every night. So each night the records that expired that day will be archived and deleted. You could of course schedule it more less frequently, but every night seems right for data that expires based on date.
Go to Top of Page
   

- Advertisement -