如何每小时在sql server中运行一个存储过程?

2021-12-05 00:00:00 cron sql database sql-server

我有一张桌子,我想每小时在上面执行一些操作.为此,我创建了一个存储过程,但不知道如何每小时调用它.我知道有一些预定的工作,但如何使用它们.

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 ?

推荐答案

在 SSMS 中导航到 SQL Server Agent-->Jobs右键单击作业文件夹并选择新作业

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

在弹出的对话框中,给工作起个名字单击步骤,然后单击新建,您将看到如下所示的对话框,选择正确的数据库并输入您的 proc 名称

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

点击日程后,选择新的,您将看到如下图所示的内容,填写您需要的所有内容并单击确定,在作业上单击确定,您应该设置

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

相关文章