After WSUS runs for a period of time, it accumulates outdated patches or computer information and does not clean up for long periods, which can cause the database to become larger and slower, and the client cannot install patches through WSUS.
WSUS provides a server Cleanup Wizard that can help us clean up WSUS. If you have not cleaned up for a long time, the data is too large, or there are some problems with the database, you may encounter database errors during the cleanup process and cannot clean up your work.
Because WSUS uses internal SQL databse, you can use the SQLCMD tool to clean up if this occurs.
Mainly consists of several parts:
Install SQL Native Client and sqlcmd tools.
Use SQLCMD to execute the index of the SQL database that rebuilt WSUS.
Get the Warp Expiration (Obsolete) ID with sqlcmd.
Delete Expired information
Re-run the Server Cleanup Wizard.
Reference Documentation:
Https://gallery.technet.microsoft.com/scriptcenter/6f8cde49-5c52-4abd-9820-f1d270ddea61#content–script for Database Maintenance
Http://www.microsoft.com/en-us/download/details.aspx?id=30440–download link to install SQLCMD utility
https://technet.microsoft.com/en-us/library/dd939795 (v=ws.10). aspx–using DB Maintenance Script
https://technet.microsoft.com/en-us/library/cc708594 (v=ws.10). Aspx–difference in WSUS 6.2 (Windows 2012)
This article is from the "Forest" blog, please be sure to keep this source http://152957.blog.51cto.com/142957/1698614
Use sqlcmd to clean up the WSUS database.