Last active
August 29, 2015 14:08
-
-
Save CreativeNotice/9db86d0b17b61882e08a to your computer and use it in GitHub Desktop.
MS SQL Get All User Roles for DBs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sp_MSForEachDB ' | |
USE [?] | |
SELECT db_name() dbname, dbU.[name] AS [user], dbGp.[name] AS [Group] | |
FROM sys.database_role_members AS dbRM | |
JOIN sys.database_principals AS dbU ON dbU.[principal_id] = dbRM.[member_principal_id] | |
JOIN sys.database_principals AS dbGp ON dbGp.[principal_id] = dbRM.[role_principal_id] | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment