Zdarzenia
31 mar, 23 - 2 kwi, 23
Największe wydarzenie szkoleniowe sql, sieci szkieletowej i usługi Power BI. 31 marca – 2 kwietnia. Użyj kodu FABINSIDER, aby zaoszczędzić $400.
Zarejestruj się już dziśTa przeglądarka nie jest już obsługiwana.
Przejdź na przeglądarkę Microsoft Edge, aby korzystać z najnowszych funkcji, aktualizacji zabezpieczeń i pomocy technicznej.
Applies to:
SQL Server
Azure SQL Managed Instance
Instructs SQL Server Agent to execute a job immediately.
Transact-SQL syntax conventions
sp_start_job
[ [ @job_name = ] N'job_name' ]
[ , [ @job_id = ] 'job_id' ]
[ , [ @error_flag = ] error_flag ]
[ , [ @server_name = ] N'server_name' ]
[ , [ @step_name = ] N'step_name' ]
[ , [ @output_flag = ] output_flag ]
[ ; ]
The name of the job to start. @job_name is sysname, with a default of NULL
.
Either @job_id or @job_name must be specified, but both can't be specified.
The identification number of the job to start. @job_id is uniqueidentifier, with a default of NULL
.
Either @job_id or @job_name must be specified, but both can't be specified.
Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
The target server on which to start the job. @server_name is sysname, with a default of NULL
. @server_name must be one of the target servers to which the job is currently targeted.
The name of the step at which to begin execution of the job. @step_name is sysname, with a default of NULL
. Applies only to local jobs.
Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
0
(success) or 1
(failure).
None.
This stored procedure is in the msdb
database.
This stored procedure shares the name of sp_start_job
with a similar object for the Azure Elastic Jobs service for Azure SQL Database. For information about the elastic jobs version, see jobs.sp_start_job (Azure Elastic Jobs).
You can grant EXECUTE
permissions on this procedure, but these permissions might be overridden during a SQL Server upgrade.
Other users must be granted one of the following SQL Server Agent fixed database roles in the msdb
database:
For details about the permissions of these roles, see SQL Server Agent Fixed Database Roles.
Members of SQLAgentUserRole and SQLAgentReaderRole can only start jobs that they own. Members of SQLAgentOperatorRole can start all local jobs, including jobs that are owned by other users. Members of sysadmin can start all local and multiserver jobs.
The following example starts a job named Weekly Sales Data Backup
.
USE msdb;
GO
EXEC dbo.sp_start_job N'Weekly Sales Data Backup';
GO
Zdarzenia
31 mar, 23 - 2 kwi, 23
Największe wydarzenie szkoleniowe sql, sieci szkieletowej i usługi Power BI. 31 marca – 2 kwietnia. Użyj kodu FABINSIDER, aby zaoszczędzić $400.
Zarejestruj się już dziś