K
K
kertok2017-12-20 14:33:56
Database administration
kertok, 2017-12-20 14:33:56

How to get the date of the user's last connection to a SQL Server 2016 database?

Actually, the essence of the question is in the title.
There is a clue - user sessions are written in the sys.dm_exec_sessions table, but for some reason not all of them.

SELECT login_name, max(last_successful_logon) as last_logged_in 
FROM sys.dm_exec_sessions 
GROUP BY login_name

I would like to know how to make it so that all users created manually through
CREATE USER test1 FOR LOGIN test1 WITH DEFAULT_SCHEMA = 'test1'

were written to this table, or an alternative to get the last successful connection to the database

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2017-12-20
@tsklab

Answer .
Especially:

If the common criteria compliance enabled server configuration option is enabled, logon statistics are displayed in the following columns:
last_successful_logon
last_unsuccessful_logon
unsuccessful_logons

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question