Export (0) Print
Expand All
Expand Minimize

How to: Create a Transact-SQL Job Step (SQL Server Management Studio)

This topic describes how to create a Microsoft SQL Server Agent job step that executes Transact-SQL scripts. These job step scripts may call stored procedures and extended stored procedures. A single Transact-SQL job step can contain multiple batches and embedded GO commands.

  1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.

  2. Expand SQL Server Agent, create a new job or right-click an existing job, and then click Properties.

    For more information on creating a job, see Creating Jobs.

  3. In the Job Properties dialog, click the Steps page, and then click New.

  4. In the New Job Step dialog, type a job Step name.

  5. In the Type list, click Transact-SQL Script (TSQL).

  6. In the Command box, type the Transact-SQL command batches, or click Open to select a Transact-SQL file to use as the command.

  7. Click Parse to check your syntax.

  8. The message "Parse succeeded" is displayed when your syntax is correct. If an error is found, correct the syntax before continuing.

  9. Click the Advanced page to set job step options, such as: what action to take if the job step succeeds or fails, how many times SQL Server Agent should try to execute the job step, and the file or table where SQL Server Agent can write the job step output. Only members of the sysadmin fixed server role can write job step output to an operating system file. All SQL Server Agent users can log output to a table.

  10. If you are a member of the sysadmin fixed server role and you want to run this job step as a different SQL login, select the SQL login from the Run as user list.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft