List all database users created for one login user

  • Hi!

    I want to see all database users (and databases for that users) that are created for one login user.

    Can anyone help?

    Thanks

  • You'd have to check each database (sysusers) and join back to syslogins.

    ms_foreachdb will help you.

  • create table #temp

    (

    dbname varchar(16),

    username varchar(30)

    )

    insert into #temp

    exec sp_MSforeachdb 'Select ''?'' as DB_Name, su.name from ?.dbo.sysusers su

    join master.dbo.syslogins sl on sl.sid=su.sid

    and sl.name=''Enter Login Name Here'''

    select * from #temp

    MJ

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

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