user list in a db

  • SELECT * FROM sys.server_principals

    above query gives list of all users on a server but how would i filter by database. I need list of users only in a particular database.

  • SELECT * FROM database.sys.database_principals

    If you need to match that up with logins...

    SELECT sp.name, dp.name

    FROM database.sys.database_principals dp

    INNER JOIN sys.server_principals sp

    ON dp.sid = sp.sid

    K. Brian Kelley
    @kbriankelley

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply