Search This Blog

Tuesday, July 22, 2008

Database Level Principals List : System Stored Procedure

Procedure Name: sp_helpuser
Definition: Reports information about database-level principals in the current database.
Syntax: sp_helpuser [ [ @name_in_db = ] 'security_account' ]

[ @name_in_db = ] 'security_account'
Is the name of database user or database role in the current database. security_account must exist in the current database. security_account is sysname, with a default of NULL. If security_account is not specified, sp_helpuser returns information about all database principals.

It returns:
Username
Groupname [User Role]
LoginName [Login for user]
DefDBName [Default database name]
DefSchemaName [Default Schema Name]
UserId [ID of username in current database]
SID [User Security Identification Number]

Example:
Exec Sp_Helpuser
it will display the stats for all available users in the current database

Or

Exec sp_helpuser 'dbo'
it will display the stats only for dbo user.

No comments: