Skip to content

Instantly share code, notes, and snippets.

@JosiahSiegel
Last active October 15, 2015 18:35
Show Gist options
  • Save JosiahSiegel/4dceef32ba5d4fb78ecb to your computer and use it in GitHub Desktop.
Save JosiahSiegel/4dceef32ba5d4fb78ecb to your computer and use it in GitHub Desktop.
#MSSQL #Research #Users Check error log for last user login
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