{"id":176,"date":"2012-03-20T17:04:48","date_gmt":"2012-03-20T17:04:48","guid":{"rendered":"http:\/\/alexboisvert.com\/musings\/?p=176"},"modified":"2012-03-20T17:04:48","modified_gmt":"2012-03-20T17:04:48","slug":"viewing-your-permissions-on-sql-server","status":"publish","type":"post","link":"https:\/\/alexboisvert.com\/musings\/2012\/03\/20\/viewing-your-permissions-on-sql-server\/","title":{"rendered":"Viewing your permissions on SQL Server"},"content":{"rendered":"<p>I wanted to see my permissions on SQL Server and Googling it was proving very hard.  So I&#8217;m adding this here in case someone might find it useful.  This will look at all the databases on the current server and list all of your permissions for each.  As a bonus, it will list the current server as well.<\/p>\n<p>[sql]<br \/>\nDECLARE @myserver sysname;<br \/>\nSET @myserver = (<br \/>\n        SELECT<br \/>\n        \ts.name<br \/>\n        FROM<br \/>\n        \tsys.servers s<br \/>\n        WHERE<br \/>\n        \ts.server_id = 0<br \/>\n    );<\/p>\n<p>SELECT<br \/>\n\t@myserver as &#8216;Server&#8217;<br \/>\n,   d.name AS &#8216;Database&#8217;<br \/>\n,   fbp.permission_name AS Permission<br \/>\nFROM<br \/>\n\t(<br \/>\n\t    SELECT<br \/>\n\t    \t&#8216;DATABASE&#8217; AS mytype<br \/>\n\t    ,   *<br \/>\n\t    FROM<br \/>\n\t    \tsys.databases<br \/>\n\t) d<br \/>\n       JOIN sys.fn_builtin_permissions(null) fbp<br \/>\n            ON  d.mytype = fbp.class_desc<br \/>\nWHERE<br \/>\n\tHas_perms_by_name(quotename(d.name) , &#8216;database&#8217; , fbp.permission_name) = 1<br \/>\nORDER BY<br \/>\n\td.name<br \/>\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to see my permissions on SQL Server and Googling it was proving very hard. So I&#8217;m adding this here in case someone might find it useful. This will look at all the databases on the current server and &hellip; <a href=\"https:\/\/alexboisvert.com\/musings\/2012\/03\/20\/viewing-your-permissions-on-sql-server\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-176","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":4,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/176\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}