Home Forums SQL Server 2008 T-SQL (SS2K8) Get all the domain and SQL users from an instance, per database RE: Get all the domain and SQL users from an instance, per database

  • First of all, thanks for your reply.

    This:

    exec sp_MSforeachdb 'select name

    from sys.database_principals

    where type in (''S'',''G'',''U'')

    and name not in (''dbo'',''guest'',''sys'',''INFORMATION_SCHEMA'',''##MS_PolicyEventProcessingLogin##'')'

    Always give me 2 results for all the databases, per instance, though I've a lot more users mapped to my DB's.

    To be clear, on instance A, i've the users 1,2,3,4,5 mapped to different databases in the instance.

    On instance B, i've the users 6,7,8,9,10 mapped to the different databases.

    The resultset of instance A is:

    DB1: 1,2

    DB2: 1,2

    DB3: 1,2

    .

    .

    .

    Though user 4 and 5 have also access to DB1 and DB2... for example.

    On instance B:

    DB1: 7,8

    DB2: 7,8

    DB3: 7,8

    .

    .

    .

    Though user 9 and 10 have also access to DB1 and DB2... for example.

    I don't know if it's normal...

    I hope this message is clear enough :-).

    Franck.