Results 1 to 5 of 5

Thread: List of users on server with Database roles

  1. #1
    Join Date
    Jan 2007
    Posts
    36

    List of users on server with Database roles

    I want to get all users with the following db roles at once on each server
    db_owner
    db_accessadmin
    db_datareader:
    db_datawriter
    db_ddladmin:
    db_securityadmin
    db_backupoperator

    is there any easiest way to do this

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Write your own script and run it on every server.

  3. #3
    Join Date
    Jan 2007
    Posts
    36
    would you give me just a hint on what tables to query to get these info.

    --- I am an Oracle DBA new guy in SQL server.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Query sysusers, sysprotects, sysmembers and syspermissions. But you can use system sps or modify them to get what you need.

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    This is what Enterprise Manager uses, this only lists db_datareader members, but you can add more insert statements for your need

    set nocount on

    create table #SQLDMOTemp (
    role_col nvarchar(132) NOT NULL,
    mem_col nvarchar(132) NOT NULL,
    id_col nvarchar(176))

    insert into #SQLDMOTemp
    (role_col, mem_col, id_col)
    exec sp_helprolemember N'db_datareader'

    select mem_col from #SQLDMOTemp

    drop table #SQLDMOTemp
    set nocount off

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •