I have a SQL Server 2008 instance with several databases and I\'m currently writing a C# application to access those databases. In this app, the end user can select a databa
You can use the system stored procedure sp_helplogins
'User Name'
You can query all databases from sys.sysdatabases
, and check if the user has access with HAS_DBACCESS:
SELECT name
FROM sys.sysdatabases
WHERE HAS_DBACCESS(name) = 1
Maybe as an alternative to Andomars answer (which I like!) you could interrogate Active Directory to see if the user is a member of a valid group for your database. I suspect this would mean you would have to maintain some Windows Group to Database Name lookup.