Display the list of users of all the bases

  • Hello everyone
    I will need to extract all users from all existing databases in my instance
    for that I found that
    exec sp_MSforeachdb 'select * from ?.sys.sysusers'
    the problem is that I want the result in a single table while with exec sp_MSforeachdb I got this result
    Who can help me solve my problem 
    thanks

  • CREATE TABLE MyUsers( dbname VARCHAR(200), principalname VARCHAR(200), principalSID VARBINARY(MAX))
    INSERT MyUsers
    exec sp_MSforeachdb 'select ''?'', name, sid from ?.sys.sysusers'

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

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