How to run a stored procedure every day in SQL Server Express Edition?

前端 未结 11 1518
野的像风
野的像风 2020-11-28 08:06

How is it possible to run a stored procedure at a particular time every day in SQL Server Express Edition?

Notes:

  • This is needed to truncate an audit t
11条回答
  •  一个人的身影
    2020-11-28 08:51

    The easiest way I have found to tackle this issue is to create a query that executes the stored procedure then save it. The query should look similar to this one below.

         use [database name]
         exec storedproc.sql
    

    Then create a batch file with something similar to the code below in it.

    sqlcmd -S servername\SQLExpress -i c:\expressmaint.sql
    

    Then have the task scheduler execute the batch as often as you like

提交回复
热议问题