1

I have a homebrewed backup system for SQL Server 2008 Express on Windows Server 2008. A scheduled task runs a .bat file, which in turns calls sqlcmd.exe to run a .sql file that backs up all of the databases to .bak files. The scheduled task works fine if I right-click on it and click Run, but when the scheduled task runs in the middle of the night, sqlcmd.exe can't connect to the server, producing the error:

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 :
Unable to complete login process due to delay in opening server connection.

I have the scheduled task set to run as myself, so the user is always the same. It's set to run whether I'm logged on or not, and set to store the password. It's also set to "run with highest privileges".

The sqlcmd.exe line of the batch script is:

"c:\program files\microsoft sql server\100\tools\binn\sqlcmd.exe" -s 127.0.0.1\SQLEXPRESS -i c:\web\backup_mssql.sql -o sqlcmd.log -b -E

I know that the docs say that the -s argument should be -S, but the command can't ever connect when I use -S.

The question is: why can this connect during the day but not when it runs automatically at night?

3
  • 2
    Just to get rid of any doubt, can you try scheduling it during the day and seeing if it runs? It seems weird that it won't run at night. You right-clicking on it and running it seems to be the only difference so I'd try to schedule it at a time when you know it runs fine to see if time is the deciding factor here at all.
    – Shane
    Sep 22, 2010 at 14:56
  • Thanks for the suggestion! I had tried that and it seemed to work. It was some kind of timing issue. See my answer on this.
    – sbleon
    Sep 23, 2010 at 16:02
  • Good stuff. These weird issues are always the hardest to figure out but often so easy to fix. Glad you got it working.
    – Shane
    Sep 23, 2010 at 16:56

1 Answer 1

1

I finally seem to have resolved the problem by changing the start time of the scheduled task from 1AM to 2AM. Something else must be heavily loading the system at 1AM so that the connection is really timing out.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .