I want to execute a query at a specific time. In MySQL we use events for that, example is as follows:
CREATE EVENT myevent ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO UPDATE myschema.mytable SET mycol = mycol + 1;
Please let me know how to do the same in SQL Server. Thanks.
PS : Sorry if its a repeated question. I tried searching for some time but didn’t get it in SQL Server
Advertisement
Answer
- You can use Sql server agent for this task and you can schedule there. Its easy way.
- Another one is “waitfor time” check this link http://msdn.microsoft.com/en-IN/library/ms187331.aspx (and you need to create a trigger with while loop logic and there wait for time is useful)
- Another one create a bat file and schedule that in windows scheduler (if you are using sql sever express edition)