Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
52.6k views
in SQL Queries by 11 11 15

I am new to SQL server, I have requested to update a table daily based on specific criteria, so I created a stored procedure in SQL server, and I want to know how I can run a stored procedure on a daily /weekly/monthly basis.

CREATE PROC spupdate
AS 
BEGIN

--do stuff update table

END

 


1 Answer

0 like 0 dislike
by 24 26 40
selected by
 
Best answer

In SQL Server, you should use JOBS to run a stored procedure based on schedule.

  1. Open SQL Server Management Studio.
  2. Expand SQL Serve Agent.
  3. Right-click on jobs and select a new job.
    new job in SQL Server

  4. Provide a name for the job and description.

  5. Click on the steps option> click new.
  6. Write the name of the step.
  7. Select the type of step.
  8. Select the database that has the stored procedure.
  9. Write the below command to execute a stored procedure.

     Exec Stored_procedure_Name
    

  10. Click Ok.
  11. Again, click on Schedule and click the new button
  12. Add the name of the schedule.
  13. Specify the time of starting job and start date as you prefer and then click ok
If you don’t ask, the answer is always NO!
...