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
 General SQL Server Forums
 New to SQL Server Programming
 Delaying trigger actions

Author  Topic 

Dmitriy
Starting Member

1 Post

Posted - 2008-11-21 : 16:57:06
Hi,

I have written a trigger in my database that will set a field called PurchaseLock to True once another column in my table has been changed. However, I want PurchaseLock to be set to true only after a certain amount of time has passed since the change, probably several hours or a day. Is this possible? I'm guessing you can't have a trigger wait 5 hours before updating a value. Could the trigger somehow schedule a stored procedure that would update the value? Or is there another way?

Thank you

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-21 : 17:46:45
You need to do this through a SQL job rather than a trigger.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2008-11-21 : 20:26:34
Why not use a trigger (or sp) to record the date & time you changed the row? That way you can work out whether 5 hours have passed using getdate().

And no you can't (well, should not) have a trigger delayed by 5 hours. Think about it. Each transaction would be 5 hours long - you could never know anything about a row until 5 hours had passed!
Go to Top of Page
   

- Advertisement -