Return to Snippet

Revision: 29768
at August 4, 2010 16:29 by hairajeshk


Initial Code
SELECT DB_NAME(database_id), LastRead = MAX(CASE
WHEN last_user_seek > last_user_scan AND last_user_seek > last_user_lookup
THEN last_user_seek
WHEN last_user_scan > last_user_seek AND last_user_scan > last_user_lookup
THEN last_user_scan
ELSE last_user_lookup
END
), LastWrite = MAX(last_user_update) FROM
(
SELECT
database_id,
last_user_seek = COALESCE(last_user_seek, '19000101'),
last_user_scan = COALESCE(last_user_scan, '19000101'),
last_user_lookup = COALESCE(last_user_lookup, '19000101'),
last_user_update = COALESCE(last_user_update, '19000101')
FROM sys.dm_db_index_usage_stats
) x
GROUP BY DB_NAME(database_id)
ORDER BY 1;

Initial URL

                                

Initial Description
To know who are the users logged in to sql server in te past previous days.

Initial Title
Find users logged in to sql server in the previous days

Initial Tags

                                

Initial Language
SQL