Skip to content

Instantly share code, notes, and snippets.

@mbourgon
Created May 12, 2015 21:19
Show Gist options
  • Save mbourgon/1e4238c5810171e84038 to your computer and use it in GitHub Desktop.
Save mbourgon/1e4238c5810171e84038 to your computer and use it in GitHub Desktop.
Eventlog_Capture - Blacklist stragglers
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO
CREATE PROCEDURE EventLog_Blacklist_Stragglers
AS
--mdb 2015/04/30 for some reason we're seeing cases where the stored procedure is called, but isn't doing anything.
-- while running single-threaded fixes it, it also takes several (4x) times longer.
-- We could also simply load everything in first, then go through and filter. However, that causes other
-- issues, like space bloat. Hence, this.
DECLARE @straggler_logs TABLE (id int IDENTITY PRIMARY KEY, computername varchar(255), eventlog varchar(255))
INSERT INTO @straggler_logs (computername, eventlog)
SELECT DISTINCT computername, eventlog FROM EventLog_Staged_PoSH
declare @min INT, @max INT, @computername varchar(255), @eventlog varchar(255)
SELECT @min = MIN(id), @max = MAX(id) FROM @straggler_logs
while @min <= @max
BEGIN
print @min
SELECT @computername = computername, @eventlog = eventlog FROM @straggler_logs WHERE id = @min
EXEC Eventlog_Blacklist_Removal @ComputerName = @computername, @EventLog = @eventlog
set @min = @min+1
END
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment