Skip to content

Dirceu Resende

DBA SQL Server and BI Analyst (PowerBI, SSAS, SSIS, SSRS)

  • CONSUTING
    • BI Consulting
    • Power BI Consulting
    • SQL Server Consulting
  • File
  • Series
    • Certification
    • Security and Audit
    • Performance tuning
    • What has changed in T-SQL?
    • Data Protection
  • Jobs
  • Data Platform Events
  • About
  • Contact

Other Languages

Subscribe to a blog by email

Enter your email address to subscribe to this blog and receive notifications of new publications by email.

Join 547 other subscribers

Blog Views

1.789.868 views

Categories

  • Apache / .htaccess (9)
  • Database (307)
    • MySQL / MariaDB (4)
    • Oracle (8)
    • SQL Server (293)
      • Audit (15)
      • Azure (2)
      • CLR (53)
      • Query Development (83)
      • DMVs and Catalog Views (31)
      • Errors (22)
      • Tools (12)
      • Data Formatting and Validation (23)
      • Little Known Features (19)
      • Hacks (17)
      • Easy (30)
      • File Handling (13)
      • Maintenance (80)
      • Monitoring (35)
      • What not to do (7)
      • OLE Automation (19)
      • Performance tuning (22)
      • Python (1)
      • Safety (39)
      • SQL Server Agent (11)
  • Business Intelligence (BI) (31)
    • Analysis Services (SSAS) (7)
    • Microsoft products (7)
    • Power BI (12)
    • Reporting Services (SSRS) (8)
  • Career and Courses (13)
  • Career, Courses and Certifications (28)
  • Cell Phones (1)
  • Events and Lectures (63)
  • Programme (57)
    • C # (CSharp) (30)
    • CSS (1)
    • ERP (1)
    • javascript (1)
    • PHP (17)
    • Powershell / CMD (8)
    • SQLCLR (4)
  • Uncategorized (10)
  • Consultancy (4)
  • Virtualization (5)

Microsoft MVP Data Platform

My Certifications

Training

Posts Archive

Recent Posts

  • Black Friday discounts on SQL Server Trainings (Buy my kkkkk course) November 27th, 2020
  • SQL Server - The “new” GREATEST and LEAST functions November 27th, 2020
  • SQL Server - How to know the date of a user's last login November 9th, 2020
  • Azure in Free Practice # 07 - Administering Databases in Azure November 5th, 2020
  • Analysis Services - An error occurred while opening the model on the workspace database. Reason: An unexpected error occurred (file 'tmcachemanager.cpp', function 'TMCacheManager :: CreateEmptyCollectionsForAllParents') November 5th, 2020
  • August 22st, 2015
  • 2
  • Database DMVs and Catalog Views Maintenance SQL Server

How to identify users logged in to SQL Server

Views: 10.094
Reading Time: <1 minute

Hello people,
Good afternoon!

In this very quick post, I will show you the usefulness of the system view. dm_exec_sessions, where we can query the connected sessions on our instance of SQL Server.

How to identify users logged in to the instance

Transact-SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SELECT
    session_id,
    login_time,
    host_name,
    program_name,
    client_interface_name,
    login_name,
    status,
    cpu_time,
    memory_usage,
    last_request_start_time,
    last_request_end_time,
    transaction_isolation_level,
    lock_timeout,
    deadlock_priority
FROM
    sys.dm_exec_sessions
WHERE
    login_name NOT IN ('sa', 'AUTORIDADE NT\SISTEMA', 'NT AUTHORITY\SYSTEM')

Connected_Users

That's it folks!
See you!

tags: active sessionsconnected usersdm_exec_sessionsidentifyidentitylistlistQueryactive sessionssqlsql servertsqllogged in usersseevisualize

You may also like ...

  • How to identify the port used by the instance of SQL Server

  • SQL Operations Studio - 64-bit Management Studio running on Windows, Linux and Mac

  • SQL Server - Querying instance information in Windows Registry using sys.dm_server_registry and xp_instance_regread

  • Next How to identify inactive sessions with open transactions in SQL Server
  • Previous How to identify jobs running via Query in SQL Server

Comments

  • Comments2
  • Pingbacks0
  1. WILLIAN said:
    23 March 2020 to 16: 34

    Obrigado!

    Reply
  2. Attilas Paiva said:
    25 January 2019 to 10: 25

    Great post.
    Is there any way to terminate connections by users?

    Reply

Leave a Comment Cancel reply

Dirceu Resende © 2021. All Rights Reserved.