| title | Add Steps to a SQL Server Agent Master Job |
|---|---|
| ms.custom | seo-lt-2019 |
| ms.date | 01/19/2017 |
| ms.prod | sql |
| ms.prod_service | sql-tools |
| ms.reviewer | |
| ms.technology | ssms |
| ms.topic | conceptual |
| ms.assetid | 9cc1e8ab-7ddc-427b-859e-203aa7e24642 |
| author | markingmyname |
| ms.author | maghan |
[!INCLUDEappliesto-ss-asdb-asdw-pdw-md] This topic describes how to add steps to a SQL Server Agent master job in [!INCLUDEssCurrent] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].
In This Topic
-
Before you begin:
-
To add steps to a SQL Server Agent master job, using:
A [!INCLUDEssNoVersion] Agent master job cannot be targeted at both local and remote servers.
Unless you are a member of the sysadmin fixed server role, you can only modify jobs that you own. For detailed information, see Implement SQL Server Agent Security.
-
In Object Explorer, click the plus sign to expand the server that contains the job to which you want to add steps.
-
Click the plus sign to expand SQL Server Agent.
-
Click the plus sign to expand the Jobs folder.
-
Right-click the job to which you want to add steps and select Properties.
-
In the Job Properties -job_name dialog box, under Select a page, select Steps. For more information on the available options on this page, see Job Properties - New Job (Steps Page).
-
When finished, click OK.
-
In Object Explorer, connect to an instance of [!INCLUDEssDE].
-
On the Standard bar, click New Query.
-
Copy and paste the following example into the query window and click Execute.
-- creates a job step that changes database access to read-only for the Sales database. -- specifies 5 retry attempts, with each retry to occur after a 5 minute wait. -- assumes that the Weekly Sales Data Backup job already exists USE msdb; GO EXEC sp_add_jobstep @job_name = N'Weekly Sales Data Backup', @step_name = N'Set database to read only', @subsystem = N'TSQL', @command = N'ALTER DATABASE SALES SET READ_ONLY', @retry_attempts = 5, @retry_interval = 5 ; GO
For more information, see sp_add_jobstep (Transact-SQL).