Who Is Connected to SQL Server? (T-SQL)
Who is connected, to which database, from where. Uses sys.dm_exec_sessions, which replaces the old sys.sysprocesses view. Works on SQL Server 2016 to 2022 and later. — Connections per database and login (SQL Server 2016-2022) SELECT DB_NAME(s.database_id) AS [Database Name], s.login_name AS [Login Name], s.host_name AS [Host Name], s.program_name AS [Program Name], COUNT(*) AS [No Of…