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.
To create a Transact-SQL job step
In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
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.
In the Job Properties dialog, click the Steps page, and then click New.
In the New Job Step dialog, type a job Step name.
In the Type list, click Transact-SQL Script (TSQL).
In the Command box, type the Transact-SQL command batches, or click Open to select a Transact-SQL file to use as the command.
Click Parse to check your syntax.
The message "Parse succeeded" is displayed when your syntax is correct. If an error is found, correct the syntax before continuing.
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.
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.