Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2016

    Unanswered: Task Scheduled SqlCmd script won't restore DB

    Hi all,

    I'm quite new to SQL Server, SQLCMD and scripting and I'm trying to restore a database periodically from a local directory using Task scheduler(Server Agent won't work) and i've set it to execute the following script:

    SqlCmd -U "SA" -P "" -S localhost -Q "RESTORE DATABASE [DAT_GUA] FROM DISK='E:/FTP/demorera/DAT_GUA.bak'"

    When I run it from Cmd it works perfect but when put in a file and ran as a script the task stays running and doesn't restore anything.

    In the add arguments field in task scheduler i've added this:

    /c start "" "C:\Users\Gestio\Desktop\restoreDB.bat"

    Also, I've tried saving the file as a .bat .vbs .cmd but no joy.

    I would appreciate any pointers on what it is I'm missing.

    -Microsoft Server 2012 R2 with an active directory environment that has been atempted to be demoted.
    -Microsoft SQL Server 2012

    Thanks ever so much for your help.


  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    So you are using Windows Task Manager instead of SQL Agent???

    First order of business, I would encourage you to switch to SQL Agent!

    If for some reason you can't use SQL Agent, then I'd hire someone to come in and run the task for you.

    If you can't do either of those then I suppose that I'd start logging the output of the batch file, keeping in mind that this is a non-trivial task. Examine that log to see what is happening or not happening during the restore attempt and respond appropriately.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jul 2003
    San Antonio, TX
    Post the contents of your script file.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Tags for this Thread

Posting Permissions

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