如何在 SQL 代理作业中执行存储过程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1216272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:03:27  来源:igfitidea点击:

How do I execute a stored procedure in a SQL Agent job?

sqlsql-servertsqlsql-server-2008sql-server-agent

提问by George2

I am using SQL Server 2008 and I need to run a SQL Job from SQL Server Agent. I am new to SQL Server Job and I want to execute a stored procedure regularly from a SQL Server Job. But I did not find where to specify the executed stored procedure other than copy & paste SQL commands.

我使用的是 SQL Server 2008,我需要从 SQL Server 代理运行 SQL 作业。我是 SQL Server 作业的新手,我想定期从 SQL Server 作业执行存储过程。但是除了复制和粘贴 SQL 命令之外,我没有找到在哪里指定执行的存储过程。

Here is my screen snapshot:

这是我的屏幕截图:

enter image description here

在此处输入图片说明

Any ideas how to assign stored procedure to execute in SQL Server Job?

任何想法如何分配存储过程以在 SQL Server 作业中执行?

回答by marc_s

You just need to add this line to the window there:

您只需要将此行添加到那里的窗口中:

exec (your stored proc name) (and possibly add parameters)

What is your stored proc called, and what parameters does it expect?

你的存储过程叫什么,它期望什么参数?

回答by Dan Diplo

As Marc says, you run it exactly like you would from the command line. See Creating SQL Server Agent Jobson MSDN.

正如 Marc 所说,您可以像从命令行一样运行它。请参阅MSDN 上的创建 SQL Server 代理作业