A job is a specified set of operations performed sequentially by SQL Server Agent. A job can perform a wide range of activities, including running Transact-SQL scripts, command-line applications, Microsoft ActiveX scripts, Integration Services packages, Analysis Services commands and queries, or Replication tasks. Jobs can run repetitive or scheduled tasks, and they can automatically notify operators of job status by generating alerts.
SQL Server Agent jobs can be used to simplify SQL Server administration and make it more efficient by automating routine administrative tasks.
Before using SQL Server jobs, make sure that the SQL Server Agent service is running.
To create a new job:
- right-click the Jobs node (within the Server Objects branch) or any object within this node in the DB Explorer tree and select the New Job item from the context menu;
- define job properties using the appropriate tabs of Job Editor.
- select the Database | New Object... main menu item;
- select Job in the Create New Object dialog;
- define job properties using Job Editor.
Hint: To create a new job, you can also select the Services | SQL Server Agent | Jobs main menu item to open the Jobs manager and select the Add Job... item from the context menu or on the Navigation bar.
To create a new job with the same properties as one of existing jobs has:
- select the Database | Duplicate Object... menu item;
- follow the instructions of Duplicate Object Wizard.
Alternatively, you can right-click a job in the DB Explorer tree and select the Duplicate Job <job_name>... context menu item.
Duplicate Object Wizard allows you to select the server to create a new job and to edit the result SQL statement for creating the job.
To edit an existing job:
- select the job for editing in the DB Explorer tree (type the first letters of the job name for quick search);
- right-click the object and select the Edit Job <job_name> context menu item, or simply double-click the job;
- edit job properties using the appropriate tabs of Job Editor.
To change the name of a job:
- select the Job to rename in the DB Explorer tree;
- right-click the job alias and select the Rename Job <job_name>... item from the context menu;
- edit the job name using the Rename Object... dialog.
To drop a job:
- select the job to drop in the DB Explorer tree;
- right-click the object and select the Drop Job <job_name>... context menu item;
- confirm dropping in the dialog window.
Note: If more convenient, you can also use the following shortcuts:
Ctrl+N to create a new job;
Ctrl+O to edit the selected job;
Ctrl+R to rename the job;
Shift+Del to drop the object.
To create, edit, rename and drop jobs, you can also use the context menu and the Navigation bar of Jobs manager.