I need a list of all the database names that my login has access - SQL help needed

  • The following SQl works but how can I add a where clause so that it only gives me a list of DBs that my login has READONLY access at minimum

    Select name FROM Sys.databases where name not in ( 'tempdb', 'master', 'ReportServer' )

  • You just need an additional condition.

    SELECT name

    FROM Sys.databases

    WHERE name not in ( 'tempdb', 'master', 'ReportServer' )

    AND HAS_DBACCESS(name) = 1;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thanks LUIS, That Worked!

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

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