How Do I Connect to the Windows Internal Database (WID)?

by | Last updated 2021.12.22 | Published on 2019.03.02 | Guides, WSUS

Connecting to the Windows Internal Database (WID) can only be done LOCALLY. It cannot be done from a remote machine. This is one of the trade-offs for using WID over SQL Express (but SQL Express carries a hard database size limit where as the WID does not).

Using SQL Server Management Studio

SQL Server Management Studio (SSMS) is by far the easiest way to graphically connect and explore the database server instance.To tell if the WID carries more than the SUSDB database, you’ll need to install SSMS and connect to the WID instance. To do this, open SSMS by using right click, “Run as administrator” and in the database server copy/paste

WID2008

np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

WID2012+

np:\\.\pipe\MICROSOFT##WID\tsql\query

Keep the setting for use Windows Authentication and click connect. It should connect successfully to the WID SQL instance. Then expand Databases and you should see SUSDB and any other databases on this instance. Expand the SUSDB, expand Tables, and you should see a listing of tables in the database.

Using PowerShell

You can use PowerShell to also connect and execute SQL commands directly to the database. You must open PowerShell in Elevated mode by “Run as administrator”. The following example will take a simple SELECT statement and return it’s values in a PowerShell variable.

WID2008:

$ConnectionString = 'server=\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query;database=SUSDB;trusted_connection=true;'

WID2012+

$ConnectionString = 'server=\\.\pipe\MICROSOFT##WID\tsql\query;database=SUSDB;trusted_connection=true;'

Take one of the lines above and add it to the PowerShell snippit below as the very first line like this example for WID2012+:

$ConnectionString = 'server=\\.\pipe\MICROSOFT##WID\tsql\query;database=SUSDB;trusted_connection=true;'
$SQLConnection= New-Object System.Data.SQLClient.SQLConnection($ConnectionString)
$SQLConnection.Open()
$SQLCommand = $SQLConnection.CreateCommand()
$SQLCommand.CommandText = 'SELECT database_id, name, user_access_desc, state_desc from Sys.Databases'
$SqlDataReader = $SQLCommand.ExecuteReader()
$SQLDataResult = New-Object System.Data.DataTable
$SQLDataResult.Load($SqlDataReader)
$SQLConnection.Close()
$SQLDataResult
RemoteApp and Desktop Connections

RemoteApp and Desktop Connections

How Do I Add RemoteApp Connections? Ever get sick of trying to find the right way of mass-adding a RemoteApp connection feed to a large amount of computers? There are a few ways: manually (YUCK!), and automatically using a GPO: User Configuration > Policies >...

WSUS Permissions – WsusContent, Registry, and IIS

WSUS Permissions – WsusContent, Registry, and IIS

If you Google WSUS Permissions, you may end up getting a boatload of links to support help on TechNet, Spiceworks, ExpertsExchange, Microsoft Docs, or other blogs around the Internet. Most of the links are only for specific parts - maybe the WsusContent folder, maybe...