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 |
|
thiyait
Yak Posting Veteran
70 Posts |
Posted - 2004-11-07 : 02:52:47
|
| hiOur application need to delete the record based on some criteria on specified date and time which should not be initiated by any one.it will be deleted automatically at specific time or date.How can i write trigger for this??? this is my queryDelete from owner_recyclebin where DATEDIFF ( dd , DeleteDate ,getdate())>=30-Thiya- |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-07 : 03:08:52
|
| You need to put your SQL in a scheduled task.Enterprise Manager : Management : RightClick Jobs : NewCheck that SQL Server Agent is runningKristen |
 |
|
|
thiyait
Yak Posting Veteran
70 Posts |
Posted - 2004-11-07 : 03:18:03
|
| thanks kristen,Is there any way to do in trigger??Anybody let me know how to ?-thiya- |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-07 : 03:37:32
|
| A trigger fires when a record is changed.You want to change some data when a value in the data becomes "stale" - i.e. at a particular date in the future.Only way to do this is to have a task that runs periodically looking for things which have become "stale"(No reason not to run the scheduled task frequently - e.g. 10 minutes is fine, every minute is OK if the task is carefully optimised and runs quickly)Kristen |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-11-07 : 17:40:13
|
| The client accessing the table should do the dynamic filtering when retrieving the data.Don't rely on the table having been "auto"-cleaned of all "old" data.It would be fine to run a scheduled task to delete from the table at periodic intervals.rockmoose |
 |
|
|
|
|
|