Unanswered: Using BACKUP from OSQL and wait for it's end
I'm writing a small vbscript to backup a db and some related files, so I used a WSShell calling OSQL to run a Sql BACKUP command, then after it's finished I XCOPY the resulting file plus some other related files. But the problem is that OSQL ends it's execution as soon as the BACKUP command is sent to SqlServer, not when the backup itself ends.
Anyone knows how to synchronize the two? How to wait, inside OSLQ, for the end of the BACKUP execution?
I don't think I've ever seen this behavior without going to some considerable effort to force it to happen. Normally OSQL waits for the batch to complete before it returns control to its caller. I suspect that you've got either a different problem, or something very peculiar in your SQL client software setup.
but in the meantime I had a suggestion from another friend: instead of WSShell calling OSQL sending BACKUP to SqlServer I tried (and it works..) a direct ADO connection from my vbs, then I issue directly the backup command.
No Pat, that's not really true, WSShell takes care of what you specify, there's a 3rd parm WAIT_ON_RETURN (1st is commandline, 2nd is window mode) that when specified tells WSShell to wait for completion. It's really OSQL that's SENDs the command 'BACKUP' to Sql Server, then returns, without waiting for any output, in fact BACKUP has no direct output... So the other solution of using an ADO connection was way better.