query for report of user logins in MSSQL

Iraj Akbari Sohi 0 Reputation points
2023-04-18T09:27:35.8833333+00:00

Hello Good time everyone Does anyone know how to get a report of user logins in MSSQL that will display the days and number of user logins and logouts in the output?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,878 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,466 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 41,101 Reputation points
    2023-04-18T09:46:35.36+00:00

    By default SQL Server don't log who logged-in in when, nor logged-out. You have to implement your own logging.

    0 comments No comments

  2. PercyTang-MSFT 12,426 Reputation points Microsoft Vendor
    2023-04-19T02:28:49.64+00:00

    Hi @Iraj Akbari Sohi

    As far as I know, you can get process information through sys.sysprocesses.

    https://learn.microsoft.com/en-us/sql/relational-databases/system-compatibility-views/sys-sysprocesses-transact-sql?view=sql-server-ver16

    But you need to get login and logout information, and there doesn't seem to be an existing query to do it.

    Best regards,

    Percy Tang

    0 comments No comments