Showing posts with label couldnt. Show all posts
Showing posts with label couldnt. Show all posts

Monday, March 12, 2012

How to find out which databases a user have access to?

Hi, my first question, tried to use search first but couldn?t find what I need.

Hopefully someone has asuggestion.

I work for a ISV producing HR applications.

When user starts the applications the program shows all databases that the user have access to. This is done by select all names from master..sysdatabases and then trying to "USE dbname" to see if user have access,. Users doesn't have sa rights.

This procedure takes approximately 90 secs for a server with 500 databases and that has become a problem.

Does anyone know off a faster method, any suggestions?

/Regards Anders

If you use the sys.databases view you will only see the databases where you have access to, as the meta data is secured in SQL Server 2005. If you are using a version prior SQL Server 2005, you will have to go through all database getting the information from the appropiate tables.


Jens K. Suessmeyer.

http://www.sqlserver2005.de