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

时间:2022-02-07 04:14:34

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 ?

是否有某种服务持续不断地运行,每一秒钟,我都可以把我要执行的代码放在那里?

3 个解决方案

#1


59  

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

在SSMS中导航到SQL Server Agent——>Jobs右键单击Job文件夹并选择new Job

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

在弹出的对话框中,给作业一个名称,单击步骤,然后在new中,您将看到如下的对话框,选择正确的DB并键入您的proc名称

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

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 如何每小时在sql server中运行一个存储过程?

点击日程表后,选择new,你会看到如下图片,填满所有你需要的东西,点击ok,点击作业上的ok,你应该被设置

#2


3  

1) Use the SQL Server Agent (open MS Management Studio) 2) New Job 3) Add Step 4) Choose Transact SQL 5) EXEC MyStroredProc 6) Choose database 7) Add schedule 8) Occurs every hour

1)使用SQL Server Agent (open MS Management Studio) 2)新工作3)Add Step 4)选择Transact SQL 5) EXEC MyStroredProc 6)选择数据库7)每小时发生一次。

Add notification to know that process is doing well (or bad).

添加通知,以了解进程运行良好(或坏)。

In the properties of SQL Server Agent check that all Auto restart options are switch ON

在SQL Server代理的属性中,检查所有自动重启选项是否都已打开

#3


1  

Set up a SQL Server agent job to execute the stored procedure at 1 hour intervals

设置一个SQL Server代理作业,以每隔1小时执行存储过程

#1


59  

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

在SSMS中导航到SQL Server Agent——>Jobs右键单击Job文件夹并选择new Job

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

在弹出的对话框中,给作业一个名称,单击步骤,然后在new中,您将看到如下的对话框,选择正确的DB并键入您的proc名称

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

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 如何每小时在sql server中运行一个存储过程?

点击日程表后,选择new,你会看到如下图片,填满所有你需要的东西,点击ok,点击作业上的ok,你应该被设置

#2


3  

1) Use the SQL Server Agent (open MS Management Studio) 2) New Job 3) Add Step 4) Choose Transact SQL 5) EXEC MyStroredProc 6) Choose database 7) Add schedule 8) Occurs every hour

1)使用SQL Server Agent (open MS Management Studio) 2)新工作3)Add Step 4)选择Transact SQL 5) EXEC MyStroredProc 6)选择数据库7)每小时发生一次。

Add notification to know that process is doing well (or bad).

添加通知,以了解进程运行良好(或坏)。

In the properties of SQL Server Agent check that all Auto restart options are switch ON

在SQL Server代理的属性中,检查所有自动重启选项是否都已打开

#3


1  

Set up a SQL Server agent job to execute the stored procedure at 1 hour intervals

设置一个SQL Server代理作业,以每隔1小时执行存储过程