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.
The WAITFOR statement suspends the execution of a connection until either:
i) specified time interval has passed.
ii) specified time of day is reached.
WAITFOR DELAY '00:00:02'
However I would not use this within a trigger. Since a trigger is fired on a event (INSERT,UPDATE,DELETE), that event will also be suspend for an hour (your example), untill the trigger has completed.
If you need to perform some sort of action after an hour, look at:
1) use xp_cmdshell to call an external program which will sleep for the hour, then connect to the DB and perform the action.
2) Look at sp_OA procedures (sp_OACreate, sp_OAMethod, ...) which could be used to run a COM object program.
3) Have the trigger load a seperate table or set a flag indicating an action to be taken, then have a seperate stored procedure perform your work for you, the procedure could be scheduled using SQL Server's scheduler to run every 15 minutes or so.