List of windows groups having sysadmin in SQL Server

Below script is used to find the list of windows groups having sysadmin in SQL server

USE master
SELECT AS [loginname] ,
        p.type ,
        p.type_desc ,
        CONVERT(VARCHAR(10),p.create_date ,101) AS [created],
        CONVERT(VARCHAR(10),p.modify_date , 101) AS [update]
FROM    sys.server_principals p
        JOIN sys.syslogins s ON p.sid = s.sid
WHERE   p.type_desc IN ( 'WINDOWS_GROUP')
        -- Logins that are not process logins
        AND NOT LIKE '##%'
        -- Logins that are sysadmins
        AND s.sysadmin = 1

1 comment:
Write comments
  1. Thanks for sharing this Informative content. Well explained. Got to learn new things from your Blog on. SQL server dba Online Training


Please do not enter spam links

Meet US


More Services