August 29, 2005 at 10:58 am
I have a script with jobs from one server, now I need to create these jobs on another server using the SQLAgent job. I forgot how to do this (I can run the script in Query Analyzer, but the point is to run it as a Scheduled Job)
Thanks!
(file could be as .sql or .txt - does it matter?)
August 30, 2005 at 3:59 am
I am not sure what you want to do. Do you want to migrate jobs to a new server once or do you want to create a job that runs a script on schedule?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 30, 2005 at 6:12 am
Need to create the job to run the script (script created already).
Have a problem to remember the command line - is it something with xp_cmdshell or ...?
Thanks!
August 30, 2005 at 6:31 am
You should just be able to execute the jobs against the msdb database on the new server, the only problem you will face is if they refer to databases that don't exist on the new one.
Hope this answers your question.
August 30, 2005 at 8:52 am
If you have the script, just create a new job on the new server, and paste the script into it. Then schedule the job to run at the desired time. Rather than schedule the job creation, I would run it manually so I can check for errors.
You may encounter problems scripting a job from one server to another. For instance, if you have notification setup for the job, you will need to have the same "email operator", or "net send operator" on the new server. Also, if you use an output file to capture job step information, you'll need the same path for the text file, or a change to your new job to a new path.
August 30, 2005 at 9:30 am
Thanks to all!
The databases will be already on the new server and jobs will be modified a little manually after all (like the email operator or output file path).
The thing I need to do - to be able to run the script from the SQLAgent job (kinda -bcp or -isql - or something else, just to pick up the .sql or .txt file and run it. Can not PASTE the code into job step - code is too big). The script will be hardcoded for the SERVER name and couple other things, will be tested to avoid any other errors , I am just crying for the command line - is it osql? just came to my mind...
August 30, 2005 at 12:05 pm
Oh, yes! it was the OSQL ! Thank you people, you made me think!
osql -SServerName -dmsdb -i"d:\MSSQL\BACKUP\TEST\TESTScript_JOBS.txt" -E
and it worked
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply