Skip to content

Instantly share code, notes, and snippets.

@jamescoxhead
Created January 11, 2016 09:49
Show Gist options
  • Save jamescoxhead/159006ca32298c58d7f7 to your computer and use it in GitHub Desktop.
Save jamescoxhead/159006ca32298c58d7f7 to your computer and use it in GitHub Desktop.
Lists any roles associated with a SQL Server user
select DBPrincipal_2.name as role, DBPrincipal_1.name as owner
from sys.database_principals as DBPrincipal_1 inner join sys.database_principals as DBPrincipal_2
on DBPrincipal_1.principal_id = DBPrincipal_2.owning_principal_id
where DBPrincipal_1.name = 'USER_NAME'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment