how to run batch jobs

  • Hi,

    Can anyone tell me how to run jobs via  .bat files?  I need to run backup jobs, as well as DTS packages.  Any documentation anywhere on this?

    tks.

     

  • Hi,

    Yep. You can schedule a job to run your bat files in SQLServerAgent. Create a job and give it a name and assign it's owner. When you go to create your steps in the job:

    Give it a step name.

    Select the type "Operating System Command (CmdExec)"

    In the command box type in the file location on the server of your batch file or a UNC network path to it including the extension. From this command box you can do pretty much anything you can do from the DOS command prompt.

    Then you can set the schedule for whenever you want.

    See "Creating Job Steps" in Books Online.

    Hope this helps,

    Martin

  • Hi,

    Thanks for that, but I didn't actually want to run it through the SQL Server Agent.  I have some backup jobs and DTS packages that currently run as jobs in SQL Server Agent, and I want to run them as a batch file.

    tks.

     

  • Whoops! Sorry about the misunderstanding. Right, my guess is you might be looking for something along the lines of the OSQL command line utility.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/coprompt/cp_osql_1wxl.asp

    If you can reduce you DTS packages to script then you can create a batch file to run the appropriate OSQL command to run the script file.

    I'm afraid I don't use it very much so I can't give you the in-depth details but there's plenty of documentation at the above link and from this list:

    http://search.microsoft.com/search/results.aspx?qu=OSQL&View=msdn&st=b&c=4&s=1&swc=4

    Hope this helps more (if not I might just run away and hide)!

    Martin

  • Thanks for the link.....I'll do a bit of reading and see if this helps...

    Its a good start!

     

  • put your scripts into a dts and use dtsrun in your bat file

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply