Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate SQL Script for SQL Server Agent 1

Status
Not open for further replies.

snyderj

MIS
Mar 2, 2001
242
US
I want to copy a SQL Server Agent job (with TSQL type steps) from server A to server B.

When I do these steps:
- Click on the job I want to copy
- Select All Tasks then Generate SQL Script
- Enter a file name
- Click OK

I get the error:
"A job step's command contains the TSQL Batch separator 'GO'. This may cause problems while running the script generated by this dialog. Use a different TSQL Batch separator while executing the generated script.

If I paste the script into Query Analyzer, the syntax check errors out all over the place and won't run.

If in the TSQL job steps I change the batch separator from GO to something else, I can generate the script just fine, and I can run the script just fine (which successfully copies it to the new server). However, the job won't run since it has a bogus TSQL Batch separators.

Am I approaching this wrong or is this a "feature"? I can't find any information about this situation in books online or on the web.

Thanks.
 
In the TSQL Job steps, you don't need GO, the end of the step automatically acts as GO. So, remove the GO all together from your jobs and then generate the script.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top