Home Forums Programming Powershell invoke-sqlcmd and stolen single user session RE: invoke-sqlcmd and stolen single user session

  • Steve Jones - SSC Editor - Friday, October 13, 2017 4:34 PM

    OK, so you lose the connection where? You're leaving something out.

    I'm quite sure I told that in opening post, though I had changed some names in that:
    2017-10-11T16:37:22.5807622Z VERBOSE: 2017-10-11 19:37:20.1067547 SET SINGLE_USER...
    2017-10-11T16:37:22.5807622Z VERBOSE: 2017-10-11 19:37:20.4348837 Rename DB...
    2017-10-11T16:37:22.6744999Z Invoke-Sqlcmd : Database 'MWA_GO_Devel' is already open and can only have one user at a time.

    I loose connection in aon11DropAndRestore.sql, after set single user. Rename db will not go through. This happens about 50% of the time.

    Lowell: As you can see, this happens inside one script..