Last active
February 6, 2018 20:53
-
-
Save Chris-ZA/efe09d076fabb62153ca247d834bb5b2 to your computer and use it in GitHub Desktop.
Script to Delete Obsolete WSUS Updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, looks like the source blog disappeared