[ Programing ]/Database

MS-SQL 사용자 계정 조회.

Mister_Q 2021. 3. 30. 09:33

SELECT @@Servername as ServerName, db_name() as DBName,_role.Name, _role.Type_Desc as RDesc, Members.Name MemberName, Members.Type_Desc as MDesc
FROM sys.database_role_members _roleMember
INNER JOIN sys.database_principals _role ON _role.Principal_Id = _roleMember.Role_Principal_Id
INNER JOIN sys.database_principals Members ON Members.Principal_Id =_roleMember.Member_Principal_Id