Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to Delete Obsolete WSUS Updates
-- This script deletes all obsolete WSUS updates from a WSUS database.
-- For more information, visit http://thebashfuladmin.com/2016/05/13/workaround-for-wsus-sql-timeout-errors/
USE SUSDB
DECLARE @UpdateID INT
DECLARE @message varchar(1000)
CREATE TABLE #ObsoleteUpdatesToCleanup (UpdateID INT)
INSERT INTO #ObsoleteUpdatesToCleanup(UpdateID) EXEC spGetObsoleteUpdatesToCleanup
DECLARE DeleteUpdates CURSOR FOR SELECT UpdateID FROM #ObsoleteUpdatesToCleanup
OPEN DeleteUpdates
FETCH NEXT FROM DeleteUpdates INTO @UpdateID WHILE (@@FETCH_STATUS > -1)
BEGIN SET @message = 'Deleting update ' + CONVERT(VARCHAR(10), @UpdateID) RAISERROR(@message,0,1) WITH NOWAIT
EXEC spDeleteUpdate @localUpdateID=@UpdateID
FETCH NEXT FROM DeleteUpdates INTO @UpdateID
END
CLOSE DeleteUpdates
DEALLOCATE DeleteUpdates
DROP TABLE #ObsoleteUpdatesToCleanup
@meoso

This comment has been minimized.

Copy link

meoso commented Feb 6, 2018

thanks, looks like the source blog disappeared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.