-3

I have a stored procedure that I want to have run every day. I have never used jobs or schedules so i'm not sure how to do this. I'm using sql server 2012 management studio.

chris
  • 78
  • 1
  • 15
  • 3
    -1 for not even attempting to research this. Googling the title of your post gives you the answer (on this site even): http://stackoverflow.com/questions/287060/scheduled-run-of-stored-procedure-on-sql-server – Siyual Jul 16 '14 at 18:16
  • 1
    i did smarty. I'm using sql agent – chris Jul 16 '14 at 18:18
  • @chris **As written** your post here shows no research effort. Also, this isn't a question. Although you are not a new user, I recommend you take a look at [the Help Center](http://stackoverflow.com/help) and head back when you have an actual, specific, programming-related question. – admdrew Jul 16 '14 at 18:20
  • 1
    If only LMGTFY wasn't blocked... – Dave C Jul 16 '14 at 18:25

2 Answers2

1

It is pretty straight forward. Here is an overview for creating a job from MSDN.

Ultimately you just create the job and your step is to EXEC yourStoredProc.

You can then create a schedule for your job to run whenever (link at the bottom of above article).

1

If it's a simple stored procedure, try the sqlcmd

http://msdn.microsoft.com/en-us/library/ms162773%28v=sql.110%29.aspx

which you can schedule in the Windows Task Scheduler. Be careful in setting up the service account it will run as, it need permissions on the database.

If it's more complex, setting up a package in SSIS (SQL Server Integration Services) gives a huge degree of power and flexibility.

Robert Sheahan
  • 2,100
  • 1
  • 10
  • 12
  • Windows Task Scheduler is unreliable compared to SQL Server jobs in my experience. – Earl G Elliott III Jul 16 '14 at 18:24
  • @Earl, what failure mode(s) have you experienced with Windows Task Scheduler that you haven't experienced with SQL Agent? What version of Windows? We've been running both TS and Agent jobs for years and have yet to experience a failure attributable to TS (though we've had permission problems on both, which is why I mentioned it). – Robert Sheahan Jul 16 '14 at 19:36
  • The most common is that it simply won't run (e.g. miss schedules). I believe the OS version it was running was 2003. Now, I did not have directly control on those machines so was just told by Ops groups that they did not work. – Earl G Elliott III Jul 21 '14 at 21:04