Shantanu Gupta
Shantanu Gupta

Reputation: 21198

How to run a stored procedure in sql server every hour?

I have a table on which I want to perform some operations every hour. For this I created a Stored Procedure but don't know how to call it every hour. I know there are some kind of scheduled jobs, but how to use them.

Is there some kind of service also that keeps on running continuously, every second, where I can place my piece of code to be executed ?

Upvotes: 45

Views: 83778

Answers (3)

garik
garik

Reputation: 5756

1) Use the SQL Server Agent (open MS Management Studio) 2) New Job 3) Add Step 4) Choose Transact SQL 5) EXEC MyStroredProc 6) Choose database 7) Add schedule 8) Occurs every hour

Add notification to know that process is doing well (or bad).

In the properties of SQL Server Agent check that all Auto restart options are switch ON

Upvotes: 4

SQLMenace
SQLMenace

Reputation: 135011

In SSMS navigate to SQL Server Agent-->Jobs Right click on the Job Folder and select new job

on the dialog that pops up, give the job a name click on steps, then on new, you will see a dialog like the following, pick correct DB and type your proc name

alt text

after that click on schedule, pick new and you will see something like the image below, fill all the stuff you need and click ok, click ok on the job and you should be set alt text

Upvotes: 74

Russ Cam
Russ Cam

Reputation: 125488

Set up a SQL Server agent job to execute the stored procedure at 1 hour intervals

Upvotes: 0

Related Questions