User database by database

  • HI,

    I would like a list in T-SQL with :

    Col1                  Col2
    database1        user1 database1, user2 database1, user3 database1....
    database2        user1 database2, user2 database2, user3 database2

    In clear, list all user by database.

    Do you have an Idea ?

    Thank you very much
    Anthony

  • Take a look at sys.database_principals, that will give you the list of each user within the database.

    You can then look at something like the undocumented sp_msforeachdb procedure to loop through each DB or you can write your own loop to look through sys.databases and switch the context.

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

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