How To
How to script jobs using Transact-SQL (Enterprise Manager)
To script jobs using Transact-SQL
- Expand a server group, and then expand a server.
- Expand Management, and then expand SQL Server Agent.
- Right-click Jobs, point to All Tasks, and then click Generate SQL Script.
- In the File name box, type a name for the script.
- Under File format, do one of the following:
- Click MS-DOS Text (OEM) to save the script in OEM format.
- Click Windows Text (ANSI) to save the script in ANSI format.
- Click International Text (Unicode) to save the script in Unicode format.
- Click MS-DOS Text (OEM) to save the script in OEM format.
- Optionally, under SQL generation options, do one or both of the following:
- Select the Replace job if it exists check box to include in the script commands to delete jobs that have the same names as the jobs generated by the script.
- Select the Include target servers check box to include in the script commands to generate target server assignments. This option is available only when scripting multiserver jobs.
- Select the Replace job if it exists check box to include in the script commands to delete jobs that have the same names as the jobs generated by the script.
- In the TSQL batch separator box, enter a Transact-SQL batch separator.