-- SQL Server Login 계정체크
SELECT Roles.Name
    ,Roles.Type_Desc
    ,Members.Name MemberName
    ,Members.Type_Desc
FROM sys.server_role_members RoleMembers
INNER JOIN sys.server_principals Roles ON Roles.Principal_Id = RoleMembers.Role_Principal_Id
INNER JOIN sys.server_principals Members ON Members.Principal_Id = RoleMembers.Member_Principal_Id
WHERE Members.name NOT LIKE '%system%' -- System's
    AND Members.name NOT LIKE '%SQLServer%' -- MSSQL2005 Servieces's
-- DB 사용자체크
SELECT @@Servername AS ServerName
    ,db_name() AS DBName
    ,Roles.Name
    ,Roles.Type_Desc AS RDesc
    ,Members.Name MemberName
    ,Members.Type_Desc AS MDesc
FROM sys.database_role_members RoleMembers
INNER JOIN sys.database_principals Roles ON Roles.Principal_Id = RoleMembers.Role_Principal_Id
INNER JOIN sys.database_principals Members ON Members.Principal_Id = RoleMembers.Member_Principal_Id

 

출처 : http://www.sqler.com/index.php?mid=bColumn&page=63&document_srl=144446

+ Recent posts