I recently installed WSUS server role on Server 2012 using WID as database. I want to create a scheduled task to run monthly to re-index the SUSDB using the wsusdbmaintenance.sql script, so I installed sql server native client 11.0 and sqlcmd utility and dropped the sql script (for troubleshooting purposes) in the same folder as the sqlcmd.exe. When ran from an administrative command prompt, I'm getting the following error message:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>sqlcmd -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i WsusDBMaintenance.sql
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could 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 instance-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 if SQL Server is configured
to allow remote connections. For more information see SQL Server Books Online..
I did type in the command (not copy and paste the command which led to others posting errors of a hyphen not actually being a hyphen)
Just because I've noticed the WID service is running under NT SERVICE\MSSQL$MICROSOFT##WID, I changed the sqlcmd to MSSQL$MICROSOFT##WID, but got the same error message. It does appear that WSUS itself is synchronizing and detecting agents just fine, which leads me to believe the availability of the actual SUSDB is ok. Looking for any help on troubleshooting error message.
I should also state, I've tried running the command with the WsusDBMaintenance.sql in the C:\temp folder to rule out permission issue as well as adding quotes to sqlcmd:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>sqlcmd -I -S "np:\\.\pipe\MSSQL$MICROSOFT##WID\sql\query" -i C:\temp\WsusDBMaintenance.sql (tried with and without the '-I')