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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to schedule a query or procedure

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-04-14 : 04:58:30
How to schedule a query or procedure in SQL SERVER 2005 to run every day at 1AM?
Can you Please help on this

Sudhakar

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-14 : 05:00:28
You can write a JOB to have a SCHEDULE ro run at your desired interval.
What the JOB can do for you, is to EXECUTE your wanted stored procedure.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

hambalang
Starting Member

4 Posts

Posted - 2009-04-14 : 07:23:17
1.In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
2.Expand SQL Server Agent, create a new job. (If SQL Server Agent was not started, right click on it and choose Start)
3.In the Job Properties dialog, click the General tag, input job name.
4.In the Job Properties dialog, click the Steps tag, and then click New.
a.In the New Job Step dialog, choose General tag, type a job Step name.
b.In the Type list, click Transact-SQL Script (TSQL).
c.Choose Database for running this job.
d.In the Command box, type the Transact-SQL command batches, or click Open to select a Transact-SQL file to use as the command. eg, we will execute the store procedure “CMS_CollectAvailableContactToCall”. So we type to the Command box “Exec CMS_CollectAvailableContactToCall” (Make sure the store procedure CMS_CollectAvailableContactToCall exists in system)
e.Click Parse to check your syntax.
f.The message "Parse succeeded" is displayed when your syntax is correct. If an error is found, correct the syntax before continuing.
g.Final, click OK
5.In the Job Properties dialog, click the Schedules tag, and then click New.
a.In the New Job Schedule dialog, type schedule Name.
b.Choose frequency Occurs, how many times, and Duration of job running. Then, click OK.
6.After finished these steps, click OK and the job is set up successfully.
Go to Top of Page
   

- Advertisement -