How to execute data base function daily once automatically
how to execute data base function daily once automatically using serveces(windows/web)
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 14, 2014, 11:00 PM EDT
Expand the SQL Server Agent node and right click the Jobs node in SQL Server Agent and select
'New Job'In the
'New Job'window enter the name of the job and a description on the'General'tab.Select
'Steps'on the left hand side of the window and click'New'at the bottom.In the
'Steps'window enter a step name and select the database you want the query to run against.Paste in the T-SQL command you want to run into the Command window and click
'OK'.Click on the
'Schedule'menu on the left of the New Job window and enter the schedule information (e.g. daily and a time).Click
'OK'- and that should be it.(There are of course other options you can add - but I would say that is the bare minimum you need to get a job set up and scheduled)
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 14, 2014, 11:01 PM EDT
SELECT GETDATE() --your query to run
raiserror('',0,1) with nowait --to flush the buffer
waitfor delay '00:00:10' --pause for 10 seconds
GO 5 --loop 5 timesit will run the query 5 times,
pausing for 10 seconds between each run
output:
Beginning execution loop -----------------------
2011-03-25 11:03:57.640 (1 row(s) affected)
-----------------------
2011-03-25 11:04:07.640 (1 row(s) affected)
-----------------------
2011-03-25 11:04:17.640 (1 row(s) affected)
-----------------------
2011-03-25 11:04:27.640 (1 row(s) affected) -----------------------
2011-03-25 11:04:37.640 (1 row(s) affected)
Batch execution completed 5 times.