Find User in SQL Server
Do any queries on SQL Server return all User created?
Do any queries on SQL Server return all User created?
On SQL Server there is a system table called sys.database_principals. You can run the above query and the result is all Users created on the database and information about them.
To retrieve all Users in SQL Server, run the following command:
SELECT *
FROM master.sys.database_principals;
System sys.database_principals includes the following columns:
COLLECTION NOTE User name created in the CREATE USER principal_id command principal code (numeric value) typeType principal:
S = User of SQL Server
U = User of Windows
G = Windows group
A = Application role
R = Database role
C = Certificate has mapped
K = Asymmetric key is mapped
Description of principal types:
SQL_USER
WINDOWS_USER
WINDOWS_GROUP
APPLICATION_ROLE
DATABASE_ROLE
CERTIFICATE_MAPPED_USER
ASSYMETRIC_KEY_MAPPED_USER
For older versions
In older versions of SQL Server, you can retrieve all Users by using the sys.sysusers table in SQL Server 2000. The command is as follows:
SELECT *COLLECTION NOTE uid user Id (unique numeric value) status Not applicable User name created in CREATE USER sid command Sid value is specified in the command CREATE LOGIN roles Not created createdate Date / Time created User by CREATE USER updatedate command Date / Time to edit User altuid Not apply password Not apply gid Group id assigned to User environ Not applicable hasdbaccess Value 0 or 1 islogin Value 0 or 1 isntname Value 0 or 1 isntgroup Value 0 or 1 isntuser Value 0 or 1 issqluser Value 0 or 1 isaliased Value 0 or 1 issqlrole Value 0 or 1 isapprole Value 0 or 1
FROM master.sys.sysusers;
See more:
- Find Login in SQL Server
- The CREATE USER command in SQL Server
Previous article: DROP USER command in SQL Server
The following article: Use annotations in SQL Server
You should read it
- USER_NAME function in SQL Server
- The CREATE USER command in SQL Server
- DROP USER command in SQL Server
- SYSTEM_USER function in SQL Server
- Function SESSION_USER in SQL Server
- How to create users in MS SQL Server
- CURRENT_USER statement in SQL Server
- Transfer from Linux Mail Server to Exchange Server 2007 (Part 3)
- How to decentralize users in MS SQL Server
- How to Unlock SQL Server Account
- What is a RADIUS Server? How does RADIUS Server work?
- Network basics: Part 3 - DNS Server
Maybe you are interested
FAST, the world's largest telescope, begins to look for life in the universe Invite to download the space theme wallpapers on the NASA XS inspired by NASA How to make delicious traditional spring rolls What is most important to men when they are in their 30s? New technology removes salt from water with the lowest energy consumption Decoding the mysterious stone that can float for years, even sinks and floats again