Unable to Connect to WSUS Database: Solved!

The saga continues… I still can’t get a successful ConfigMgr software update sync from my WSUS server. The latest issue is now I couldn’t access the Windows Internal Database to run any kind of maintenance script. When trying to connect either via sqlcmd or Management Studio via my logged in Windows credentials I was receiving the error system cannot find the file specified when attempting to connect with the server name nb:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query  and the error login failed when connecting with the server name nb:\\.\pipe\MICROSOFT\##WID\tsql\query . Also, event ID 18456 – Token-based server access validation failed with an infrastructure error… was being generated in the Application event log along with Login failed for user…. server is in script upgrade mode in the C:\Windows\WID\Log\error.log.

Microsoft support suspected problems with the WID so we had to get SQL access to it. To anyone that’s trying to access the WSUS Windows Internal Database via SQL Server Management Studio Express and cannot get connected, here’s what I had to go through:

    1. Download and install SQL Server Management Studio Express.
    2. Open up SQL Server Configuration Manager and go to Native Client 11.0 Configuration -> Client Protocols and ensure TCP/IP is enabled.
    3. Connect to database on command line via  sqlcmd -S np:\\.\pipe\MICROSOFT##WID\tsql\query
    4. Execute the query

For some reason, this fixed the connection issue and we were now able to connect!

Adam Bertram

Chief Automator at Adam the Automator, LLC
Adam Bertram is an independent consultant, technical writer, trainer and presenter. Adam specializes in consulting and evangelizing all things IT automation mainly focused around Windows PowerShell. Adam is a Microsoft Windows PowerShell MVP, 2015 powershell.org PowerShell hero and has numerous Microsoft IT pro certifications. He authors IT pro course content for Pluralsight, is a regular contributor to numerous print and online publications and presents at various user groups and conferences.You can find Adam here on the blog or on Twitter at @adbertram.

Latest posts by Adam Bertram (see all)


  • Hi! i try to run this command in my WID 2012 and SQL retorned a error: ‘Msg 4145, Level 15, State 1, Line 1
    An expression of non-boolean type specified in a context where a condition is expected, near ‘;’.
    Msg 102, Level 15, State 1, Line 3
    Incorrect syntax near ’53’.’

    Can you help me?
    Thanks a lot!

  • I have the same event id 18456 while connecting to my TFS database .Reason : Failed to open the explicitly specified database . The account is an internal service account . Any thoughts ?

  • And it should be -S, not -s. With the lower case option, I get “login timeout”, with upper case, an SQL prompt.

  • i am unable to connect to sql using command line:

    C:\Windows\system32>sqlcmd -s np:\\.\pipe\MICROSOFT##WID\tsql\query
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: C
    ould not open a connection to SQL Server [2]. .
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in
    stance-specific error has occurred while establishing a connection to SQL Server
    . Server is not found or not accessible. Check if instance name is correct and i
    f SQL Server is configured to allow remote connections. For more information see
    SQL Server Books Online..

  • You should put the comment from Dane Watson on top of your blog, as this is really all that is needed. Only .\administrators have a login for that instance and so you you have to “run as administrator”. Seems that you opened slqcmd as admin, because you would have gotten the same “login failed” if you had not.
    And I cannot see how that selects could fix a problem..

    • That would be a completely different issue than the one this one is addressing. This one is for people with an event log stating “Login failed for user…. server is in script upgrade mode in the C:\Windows\WID\Log\error.log.”
      Simply running as admin did not run for me without clearing the lock.

  • I found that I needed to start SQL Server Management Studio as an administrator to automatically get authenticated. I didn’t need to do the script

  • I THINK you have a typo still in that connect string. I believe it should be: sqlcmd -s np:\\.\pipe\MICROSOFT##WID\tsql\query

    Note the removal of the backslash after Microsoft.

Leave a Reply