Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2006
    Posts
    3

    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?
    TIA
    Luigi

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    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.

    -PatP

  3. #3
    Join Date
    Aug 2006
    Posts
    3
    Thanks Pat,
    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.
    Bye
    Luigi

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Ah-ha! WSShell is asynchronous, so that's where your problem was, not in OSQL at all!

    -PatP

  5. #5
    Join Date
    Aug 2006
    Posts
    3
    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.
    Cheers
    Luigi

Posting Permissions

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