Created
February 16, 2018 14:00
-
-
Save richardbasile/c645c3237ca26d023a1d8dd37d9bc28f to your computer and use it in GitHub Desktop.
SQL Server - Failed Logins
This file contains hidden or 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
declare @Time_Start datetime = getdate()-7; | |
declare @Time_End datetime = getdate(); | |
-- Create the temporary table | |
DECLARE @ErrorLog TABLE (logdate datetime | |
, processinfo varchar(255) | |
, Message varchar(500)) | |
-- Populate the temporary table | |
INSERT @ErrorLog (logdate, processinfo, Message) | |
EXEC master.dbo.xp_readerrorlog 0, 1, null, null , @Time_Start, @Time_End, N'desc'; | |
-- Filter the temporary table | |
SELECT * --LogDate, Message | |
FROM @ErrorLog | |
WHERE (Message LIKE '%error%' OR Message LIKE '%failed%') | |
ORDER BY logdate DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment