Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Get list of users for Database

Author  Topic 

BryanBurroughs
Starting Member

8 Posts

Posted - 2010-05-12 : 14:04:59
Howdy all,
I've got a SQLServer 2005 (*gasp*) installation on Win2k3 Server and am trying to get a list of the users that have access to the database. I've set up a view as follows:

SELECT SUSER_SNAME(sid) AS UserName
FROM sys.database_principals
WHERE (type = 'U')

This view works exactly as I would expect for some users, but for others it does not show all of the users. I am guessing it's a permission problem somewhere. Any ideas as to what permission I need to set?

malpashaa
Constraint Violating Yak Guru

264 Posts

Posted - 2010-05-12 : 16:03:58
For now I can think for two reasons that may cause this:
1- This system view is related to the database you are currently using. So assure that are in the correct database before running the query.
2- This system view is limited to what you (the user running the query) has been granted permission.
I think that it is the first reason. So check it first.
Go to Top of Page
   

- Advertisement -