Oops, I think this is a little better:
[font="Courier New"]SELECT
DB_NAME() AS database_name,
MP.name AS database_user,
RP.name AS database_role,
SP.name AS server_login,
SPR.name AS server_role
FROM
sys.database_principals MP LEFT JOIN
sys.database_role_members R ON
MP.principal_id = R.member_principal_id LEFT JOIN
sys.database_principals RP ON
R.role_principal_id = RP.principal_id LEFT JOIN
sys.server_principals SP ON
MP.sid = SP.sid LEFT JOIN
sys.server_role_members SRM ON
SP.principal_id = SRM.member_principal_id LEFT JOIN
sys.server_principals SPR ON
SRM.role_principal_id = SPR.principal_id[/font]
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question