none
how find list of all user in sql database

    Question

  • I would like to ask another question how to find list of all the users or logins in sql server

     

    best regard
    tankao

    Wednesday, June 18, 2008 8:53 AM

Answers

  • Database principals:

    SELECT * FROM sys.database_principals

     

    Server logins:
    SELECT * FROM sys.server_principals

     

    Wednesday, June 18, 2008 9:11 PM
    Moderator

All replies

  • The simplest way to list all users and processes is to use the system stored procedure:

    sp_who

    to list all active users:

    sp_who 'active'

    to list details about a particular user:

    sp_who 'login-name'

    the same information (and more) can be found by interrogating the system table master..sysprocesses, for example the following is equivalent to 'sp_who':

    select spid, status, loginame, hostname, blocked, db_name(dbid), cmd from master..sysprocesses

    but the table master..sysprocesses also provides additional information such as the login_time, program_name and others. For full details of the master..sysprocesses table refer to SQL Server Books Online.

     

    Hope this helps.

    Wednesday, June 18, 2008 9:07 AM
  • Database principals:

    SELECT * FROM sys.database_principals

     

    Server logins:
    SELECT * FROM sys.server_principals

     

    Wednesday, June 18, 2008 9:11 PM
    Moderator
  • Is there any way to list all users for all databases?

    Sunday, September 23, 2012 6:51 PM