Compartilhar via


How to: Create a SQL Server Agent Job (Transact-SQL)

This topic describes how to use stored procedures to create a Microsoft SQL Server Agent job.

To create a SQL Server Agent job

  1. Execute sp_add_job to create a job.

  2. Execute sp_add_jobstep to create one or more job steps.

  3. Execute sp_add_schedule to create a schedule.

  4. Execute sp_attach_schedule to attach a schedule to the job.

  5. Execute sp_add_jobserver to set the server for the job.

Local jobs are cached by the local SQL Server Agent. Therefore, any modifications implicitly force SQL Server Agent to re-cache the job. Because SQL Server Agent does not cache the job until sp_add_jobserver is called, it is more efficient to call sp_add_jobserver last.

See Also

Concepts

Creating Jobs

Other Resources

System Stored Procedures (Transact-SQL)
sp_add_job (Transact-SQL)
sp_add_jobstep (Transact-SQL)
sp_add_schedule (Transact-SQL)
sp_attach_schedule (Transact-SQL)
sp_add_jobserver (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance