Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

SQL Server users management

Posted on by Microsoft Employee

Hello to all,

From where I can find who are login in accessing the SQL Server 2012 database and how to kill the session?

Best wishes

*This post is locked for comments

  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: SQL Server users management

    Hello,

    IF you execute Tharanga SQL Query, the Field Login (3'rd Field) in Result Windows provides you the Windows Login ID of the User.

    That is the User who is accessing the Navision.

    ** For Any Client Running RTC the Output will not be correct, For Role Tailored Client The Query will show you the User as the User who is Set to Run the Services for Navision.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SQL Server users management

    Hello Tharanga,

    It work but need to specify me which user is this?

    best regards,

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: SQL Server users management

    to get the users of your nav database write

    SELECT [User Name]  FROM [<your db>].[dbo].[User]

  • TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: SQL Server users management

    Please do start new threads for your new questions and please do verify the answers.

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: SQL Server users management

    Use below query :

    DECLARE @Table TABLE(
           SPID INT,
           Status VARCHAR(MAX),
           LOGIN VARCHAR(MAX),
           HostName VARCHAR(MAX),
           BlkBy VARCHAR(MAX),
           DBName VARCHAR(MAX),
           Command VARCHAR(MAX),
           CPUTime INT,
           DiskIO INT,
           LastBatch VARCHAR(MAX),
           ProgramName VARCHAR(MAX),
           SPID_1 INT,
           REQUESTID INT
    )
    
    INSERT INTO @Table EXEC sp_who2
    SELECT  *
    FROM    @Table
    WHERE DBName = 'YourNAVDBName'

    You can get all the information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine from 'sp_who2' stored procedure.

    Read more about sp_who2

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SQL Server users management

    How to find users who using Microsoft Dynamic NAV database?

  • Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: SQL Server users management

    IF you are looking for all Logins in SQL SErver then run below command -

    SELECT * FROM sys.server_principals

  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: SQL Server users management

    You want list of active users or all the users in sql.

    The Above results show you active users in SQL with database name that they are using.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SQL Server users management

    HI,

    I need the list of users it give me following details.

    Screenshot_5F00_2.png

    regards,

  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: SQL Server users management

    Try this -

    It list all users connected to database -

    SELECT

       DB_NAME(dbid) as DBName,

       COUNT(dbid) as NumberOfConnections,

       loginame as LoginName  

    FROM

       sys.sysprocesses

    WHERE

       dbid > 0

    GROUP BY

       dbid, loginame

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans