0

Is it possible to create a list of all the databases where a specific user can access?

For example,

My user is 'Domain\MarySmith'. This user can access on a single database or can access many databases.

I need a query like this:

SELECT All_Db_Name_I_Can_Acces 
FROM ServerSql 
WHERE Username = 'Domain\MarySmith'
0

1 Answer 1

0

Try with this

USE master;
GO
EXECUTE AS LOGIN = N'LoginName';
GO
SELECT name
FROM sys.sysdatabases
WHERE HAS_DBACCESS(name) = 1
GO
REVERT;
1
  • Great !!! Thank you
    – Alan392
    Commented Jul 5, 2019 at 7:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.