Add a Job Step to an Existing SQL Server Agent Job (T-SQL)

When you create a SQL Server Agent job with T-SQL, you use the sp_add_jobstep stored procedure to add each job step.

If you ever need to add a new step to that job, you can use sp_add_jobstep once again to add the new job step.

But you may also need to modify the existing step, depending on how you’d like the job to progress through the steps.

Continue reading

Update a Job Step for a SQL Server Agent Job (T-SQL)

In SQL Server, you can use the sp_update_jobstep stored procedure to modify an existing job step of a SQL Server Agent job.

When you create a SQL Server Agent job, you create one or more job steps for that job. The sp_update_jobstep procedure allows you to update a specific job step independent of the actual job or any other job steps.

Continue reading

How to Use the Same Schedule for Multiple SQL Server Agent Jobs (T-SQL)

When you create a SQL Server Agent job, you have the option of creating a new schedule for that job or using one that already exists.

Job schedules can be managed independently of jobs. You can use sp_add_schedule to create the schedule and sp_attach_schedule to attach the schedule to a job.

This enables you to attach the same schedule to multiple jobs.

Continue reading

Create a SQL Server Agent Job using T-SQL

SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks, which are called jobs in SQL Server.

T-SQL includes a large collection of stored procedures that deal with SQL Server Agent jobs.

Here, we’ll use some of them to create and schedule a SQL Server Agent job.

You can also create SQL Server Agent jobs via the GUI (in SSMS) if you prefer.

Continue reading