Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function Sleep in SQL Server???

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need some help on SQL Server.
I need to create a trigger on the update of a particular field in a table.
This trigger has to perform some action after an hour since this field is updated.
Java has a sleep function, does SQL also have something like that.

Thanks and Regards,
Parul
 
There is a WAITFOR command (See BOL for details)
Not sure you would want to put this in a trigger, as I think this just pauses SQL Server.
 
Can you not store a result from GetDate() in a variable and add one hour to it.

Then set a while loop with an exit clause that says when the current date is greater than or equal to that variable.

I suppose this is a waste of processing power, though.
 
I don't think you want to put any sort of delay in a trigger. The original transaction is not complete until all triggers are processed.

One thing you could do is have the trigger insert a row into a jobs table and have another process act on data in that table at some future time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top