Task Scheduler problem

  • Don't know if this is the correct forum - please correct me if I'm wrong.
    Attempting to run a backup script via task scheduler. Running the back ups script in SSMS works fine. Task fails with a (0x1) result.  Ran into this once before, with no understanding of what caused it. That was resolved by deleting the task and rebuilding and it ran properly. Tried that here, only to get the same result.

    In task scheduler, used "Create task" with the following:

    Program script set to: "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"

    Add arguments:-S servername -E -i x:\Test\Back ups script.sql

    Back ups script.sql:
    BACKUP DATABASE databasename TO DISK = N'X:\SQLBackups\Back up file.bak'
    WITH NOFORMAT, NOINIT, NAME = N'Full Database Backup name', SKIP, NOREWIND, NOUNLOAD, STATS = 10

    All of this looks good.
    Server specs: Windows Server 2012 R2 Standard.

    SQL Server Version: Microsoft SQL Server 2012 - 11.0.2100.60 (X64) Feb 10 2012 19:39:15 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)

    Task scheduler is not working for whatever reason. Can't use sql server logs, this is outside of SQL Server.

    Any ideas on how to resolve this?  Comments / URLs are appreciated.  Thanks.

  • When I've used Windows Task Scheduler to setup items like this, I tend to use a CMD script file, with code like this in it:

    ECHO Backup Database Full: %date% %time% >>BackupDBfull_log.txt
    SQLCMD -S myservername -E -i BackupDBfull.sql -X >>BackupDBfull_log.txt
    EXIT

    so that I can capture any output into a text file.  Some things I can think of to check:
    -  in Security Options section of the General tab, what user account do you have the job using?  Make sure it has permissions to the folder where your SQL script is and that it has proper permissions within the database to do a backup.
    -  do you have the option "Run whether this user is logged on or not" selected?

    ensuring the permissions are good and logging the output to a text file should help you troubleshoot this better.

  • bobba - Wednesday, January 25, 2017 1:59 PM

    Don't know if this is the correct forum - please correct me if I'm wrong.
    Attempting to run a backup script via task scheduler. Running the back ups script in SSMS works fine. Task fails with a (0x1) result.  Ran into this once before, with no understanding of what caused it. That was resolved by deleting the task and rebuilding and it ran properly. Tried that here, only to get the same result.

    In task scheduler, used "Create task" with the following:

    Program script set to: "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"

    Add arguments:-S servername -E -i x:\Test\Back ups script.sql

    Back ups script.sql:
    BACKUP DATABASE databasename TO DISK = N'X:\SQLBackups\Back up file.bak'
    WITH NOFORMAT, NOINIT, NAME = N'Full Database Backup name', SKIP, NOREWIND, NOUNLOAD, STATS = 10

    All of this looks good.
    Server specs: Windows Server 2012 R2 Standard.

    SQL Server Version: Microsoft SQL Server 2012 - 11.0.2100.60 (X64) Feb 10 2012 19:39:15 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)

    Task scheduler is not working for whatever reason. Can't use sql server logs, this is outside of SQL Server.

    Any ideas on how to resolve this?  Comments / URLs are appreciated.  Thanks.

    For your command/script try using quotation marks around the paths with the commands on one line (instead of using arguments) - along the lines of:
    "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE" -S YourInstanceName -i "x:\Test\Back ups script.sql"

    Sue

  • Issue is resolved.  It's a named instance, once it was modified to include the name - it worked.

    The syntax was something like this:
    Program/Script
    "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"

    Add arguments
    -S (local)\instancename -i "D:\Test\SQLExpressBackups.sql"

    Thank you Sue + Chris.  Support was appreciated.

Viewing 4 posts - 1 through 3 (of 3 total)

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