I wanted to see who in my database has db_owner rights. Here is the script that worked:
SELECT m.name
FROM sys.database_role_members AS rm
JOIN sys.database_principals AS p
ON rm.role_principal_id = p.principal_id
JOIN sys.database_principals AS m
ON rm.member_principal_id = m.principal_id
WHERE p.name = N'db_owner'
AND m.name NOT IN (N'dbo', N'SQLServiceAct')
ORDER BY m.name
name
-----------
[result1]
[result2]
Based on a script pulled from an entry here by "The Scary DBA".
No comments:
Post a Comment