Who is in the DBO group for all dbs.

  • Hi

    I need a script as part of a security audit. Any pointers would help.

    Even a table name where this stored will do.

  • I'm not sure what you are asking with this question. If you want a table to list every principal on the server you can use sys.server_principals



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • I need to know who is in the DBO role for each database on my server.

    Via a script.

  • Here is the query:

    SELECT

    USER_NAME(memberuid) as Member

    ,USER_NAME(groupuid) as [Group]

    FROM

    sys.sysmembers

    WHERE

    USER_NAME(groupuid) = 'db_owner'

    and you can use sp_MSforeachdb to run it for all databases on your server.



    Microsoft Certified Master - SQL Server 2008
    Follow me on twitter: @keith_tate

    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Excellent. Nice one. Never used Sysmembers. Every day is a school day.

  • sys.sysmembers (Transact-SQL)

    This SQL Server 2000 system table is included as a view for backward compatibility. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    The 2008 equivalent is sys.database_role_members.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

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