Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2007
    Posts
    20

    Unanswered: Schedule SQL script

    I been trying to figure out how to do this for a while but finally given in and decided to ask here.
    I am using SQL express and I think that desnt support automation of SQL scripts (please correct me if I am wrong!)

    I want to run a backup script and the plan was to use a bat file and windows task scheduler. But for the life of me I cannot get the bat file to work after trying loads of different example from my searches.

    Any help is apreciated

  2. #2
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    I think you are correct that express doesn't include Agent, which is the scheduling component that comes with the higher SKUs of sql server.

    what does the bat file look like? are you using sqlcmd.exe? that's what I would recommend.

  3. #3
    Join Date
    Apr 2007
    Posts
    20
    hmm does it have to be called sqlcmd.exe?
    I had a file called script.bat and i was writing a one line command to execute the SQL script. I really dont have any idea what im doing I was just following what some forums were saying when I searched

    thanks

  4. #4
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    sqlcmd.exe is a console app you can use to execute sql scripts from the cmd line. the equivalent in 2000 is osql.exe.

  5. #5
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I'm guessing here but I would say that you can pass parameters to sqlcmd.exe can you not? So you could call sqlcmd.exe <parameter1> <parameter2> ... from your batch file and it should run your backup commands for you.

    How to connect using SQLcmd
    How to execute commands from SQLcmd
    A break down of SQLcmd options <-- CHECK THIS ONE OUT.

    Bear in mind that your batch script needs to know where the sqlcmd is run from. So it either needs to be in your PATH setting or you need to run your batch script from the same directory (not advisable).
    Last edited by aschk; 05-14-07 at 05:36.

  6. #6
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by Paul.
    I really dont have any idea what im doing
    You might want to take a step back and make yourself familiar with the SQL Server environment and all the tools that come with it before trying to actually implement something.
    Sometimes it's quicker to read the manual first and only then start "coding", instead of trying to cleanup the mess you made because you "don't have any idea what you are doing".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •