Last active
October 15, 2015 18:35
-
-
Save JosiahSiegel/4dceef32ba5d4fb78ecb to your computer and use it in GitHub Desktop.
#MSSQL #Research #Users Check error log for last user login
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 @temp_error_log TABLE | |
( | |
date datetime, | |
process varchar(50) null, | |
text varchar(MAX) null | |
) | |
INSERT INTO @temp_error_log | |
EXEC sp_readerrorlog 0, 1, 'Login' | |
SELECT DISTINCT MAX(date) as 'date', text as 'activity' FROM @temp_error_log | |
WHERE process = 'Logon' | |
GROUP BY text, process | |
ORDER BY MAX(date) desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment