Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

How to automatically run a stored procedure in SQL Server 2005

From a recent email:

Customer has SOP batches that are created periodically without transactions in them and they want to clean them out on a regular basis.  I have the script to do so but now I want to create a scheduled task in SQL Server 2005 to run this during off hours, say, weekly.  What is the best way to accomplish this task?  Customer is now running GP v10 but in this case, I don’t think it matters since table structures have not changed that I know of within this scenario.

 Answer:

In SQL Server Management Studio, expand SQL Server Agent and right click on Jobs. Choose 'new job'

In the 'New Job' window, enter in a job name and description, then click on 'Steps'

Click 'New' at the bottom of the window to create a new step

In the 'New Job Step' window, enter in a step name, and a command to run the stored procedure. Or, if the code is simple enough, you could just paste the code here directly and skip the procedure. Click 'OK' to close this window.

Back in the 'New Job' window, click on 'schedules', click 'New' at the bottom of that window, and assign the job a schedule in the 'New Job Schedule' window. Any of the hilighted areas are applicable, you'll just choose the ones that are good for you.

Comments

No Comments

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.