If you run a Windows Server Update Services (WSUS) server, you know that sometimes it can develop problems. Specifically the WSUS database can need a manual clean up. There are several scripts around that handle this but I found one HERE that helped me quite a bit.
If you are running WSUS from a Windows Internal Database on Server 2012 enter the following command: . sqlcmd -I -S \\.\pipe\MICROSOFT##WID\tsql\query -i C:\WsusDBMaintenance.sql . If you are running WSUS from a from a Windows Internal Database on Server 2008 or SBS 2011, enter the following command: . sqlcmd.exe -I -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i C:\WSUSDBMaintenance.sql .updated Jul 18 2018 (Be sure adjust the path of C:\WsusDBMaintenance.sql to reflect where you actually put the script) .
Wait.
I have not had this take more than 15 minutes but I have read reports of it taking a VERY long time.
I found THIS post and THIS post helpful when dealing with the WSUS problem.
The commands in your post were command prompt commands (rather than PowerShell commands) that relied on certain sql server components being installed on your server, the listed commands and corresponding sql script didn't work for me but I was able to accomplish the same thing using a reindexing tsql script published by Microsoft using the Invoke-Sqlcmd PowerShell command, and that the links to the Microsoft technet articles included in your article are no longer redirecting to the articles they were intended to redirect to and were instead redirecting to a generic Microsoft code sample page.
hello im runing my wsus on a sql express data base and it reach the limit of 10gb
can sync anymore what can i do ?
I have this script running for the last 28 hours and its still not finished. In task manager i see that the sql server windows nt process is using cpu and a ton of memory.
So should i exit the script or continue.
I would let it run for a full three days as long as it was doing something with the CPU.
Requirements to execute are:
Microsoft® ODBC Driver 11 für SQL Server® – Windows
Microsoft® Command Line Utilities 11 for SQL Server®
whatif: I don't have the SqlCmd? (sqlcmd : The term 'sqlcmd' is not recognized as the name of a cmdlet,... etc)
That likely means WSUS is not installed on that machine OR WSUS is not using the integrated database. If you are sure WSUS is on that server, check to see if its database is stored on a full SQL server.
I also have this error, my WSUS is based on the windows (WID) itself.
WinServer 2019 v: 1809
WSUS 10.0.17
Thank you, sir. This saved the day and a lot of unnecessary work rebuilding.
2nd command is wrong above. It should be:
sqlcmd.exe -I -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i C:\WSUSDBMaintenance.sql
Thanks Rob. I have corrected that typo :)
Hi, I'm trying to run the command for a SBS2011, but PowerShell halts with a prompt ">>", so it seems like there's something wrong with the command
Hi Mats;
I have seen these scripts take an hour to complete, but I have never seen them fail. Are you sure you are running POWERSHELL as an Admin (check the title bar).
Hi - Will this script clean the WSUS data in Windows Internal Database (WID) - i'm running WSUS on windows server 2016.
Thanks, Abs
View Comments
FROM: Nathan S
The commands in your post were command prompt commands (rather than PowerShell commands) that relied on certain sql server components being installed on your server, the listed commands and corresponding sql script didn't work for me but I was able to accomplish the same thing using a reindexing tsql script published by Microsoft using the Invoke-Sqlcmd PowerShell command, and that the links to the Microsoft technet articles included in your article are no longer redirecting to the articles they were intended to redirect to and were instead redirecting to a generic Microsoft code sample page.
hello im runing my wsus on a sql express data base and it reach the limit of 10gb
can sync anymore what can i do ?
That is an excellent question and our answer is to stop storing patches locally altogether. We just changed ALL of our clients to the 'new' preferred method and have not had any problems: https://www.urtech.ca/2020/01/solved-how-to-change-wsus-to-download-patches-directly-from-ms-and-not-store-updates-locally/
Let us know if you want assistance.
hello im runing my wsus on a sql express data base and it reach the limit of 10gb
can sync anymore what can i do ?
That is an excellent question and our answer is to stop storing patches locally altogether. We just changed ALL of our clients to the 'new' preferred method and have not had any problems: https://www.urtech.ca/2020/01/solved-how-to-change-wsus-to-download-patches-directly-from-ms-and-not-store-updates-locally/
Let us know if you want assistance.
Will this work for a wsus running server 2016?
Yes it will
I have this script running for the last 28 hours and its still not finished. In task manager i see that the sql server windows nt process is using cpu and a ton of memory.
So should i exit the script or continue.
I would let it run for a full three days as long as it was doing something with the CPU.
Requirements to execute are:
Microsoft® ODBC Driver 11 für SQL Server® – Windows
Microsoft® Command Line Utilities 11 for SQL Server®
(found this hint at https://www.hass.de/content/reindex-wsus-database-under-windows-2012)
whatif: I don't have the SqlCmd? (sqlcmd : The term 'sqlcmd' is not recognized as the name of a cmdlet,... etc)
That likely means WSUS is not installed on that machine OR WSUS is not using the integrated database. If you are sure WSUS is on that server, check to see if its database is stored on a full SQL server.
I also have this error, my WSUS is based on the windows (WID) itself.
WinServer 2019 v: 1809
WSUS 10.0.17
Thank you, sir. This saved the day and a lot of unnecessary work rebuilding.
2nd command is wrong above. It should be:
sqlcmd.exe -I -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -i C:\WSUSDBMaintenance.sql
Thanks Rob. I have corrected that typo :)
Hi, I'm trying to run the command for a SBS2011, but PowerShell halts with a prompt ">>", so it seems like there's something wrong with the command
Hi Mats;
I have seen these scripts take an hour to complete, but I have never seen them fail. Are you sure you are running POWERSHELL as an Admin (check the title bar).
Hi - Will this script clean the WSUS data in Windows Internal Database (WID) - i'm running WSUS on windows server 2016.
Thanks, Abs
Yes, I believe it will.