{"id":545,"date":"2017-09-19T09:40:29","date_gmt":"2017-09-19T14:40:29","guid":{"rendered":"http:\/\/www.sqlnuggets.com\/?p=545"},"modified":"2017-09-19T09:40:29","modified_gmt":"2017-09-19T14:40:29","slug":"sql-scripts-change-owner-database","status":"publish","type":"post","link":"https:\/\/sqlnuggets.com\/sql-scripts-change-owner-database\/","title":{"rendered":"SQL Scripts: How To Change The Owner Of A Database"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-550\" src=\"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280-1024x578.jpg\" alt=\"\" width=\"800\" height=\"452\" srcset=\"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280-1024x578.jpg 1024w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280-300x169.jpg 300w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280-768x433.jpg 768w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg 1280w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Sometimes it becomes necessary to change the owner of a database. \u00a0When a database is first created, SQL Server likes to set the owner of that database to the login of whoever created it. \u00a0This also seems to be the case when restoring a database,\u00a0the owner is set to the login that does the restore.<\/p>\n<p>To see which login has been assigned as owner of your databases, you can query the <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/system-catalog-views\/sys-databases-transact-sql\" target=\"_blank\" rel=\"noopener\">sys.databases<\/a> view:<\/p>\n<pre class=\"lang:tsql decode:true\">SELECT [name], SUSER_SNAME(owner_sid) \r\nFROM sys.databases<\/pre>\n<p>You may be surprised at the account listed as the owner of your databases. \u00a0You may also be confused between the differences in the &#8220;owner of a database&#8221;, the &#8220;dbo&#8221; user\/schema, and the &#8220;db_owner&#8221; permission role, all of which can sometimes be\u00a0referred to as &#8220;Database Owner&#8221;. \u00a0The accepted answer in this <a href=\"https:\/\/dba.stackexchange.com\/questions\/18610\/what-is-the-purpose-of-the-database-owner\" target=\"_blank\" rel=\"noopener\">Stack Exchange<\/a> post should help to clarify that.<\/p>\n<p>If you find from the query above that you need to change the owner of a database, this can easily be done by running a simple T-SQL statement.<\/p>\n<h4>The Old Way:\u00a0sp_changedbowner<\/h4>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/system-stored-procedures\/sp-changedbowner-transact-sql\" target=\"_blank\" rel=\"noopener\">sp_changedbowner<\/a> has been around since at least SQL Server 2000, although the docs seem to indicate SQL Server 2008. \u00a0Using this procedure is pretty straight forward, just execute it on the database you wish to change ownership for, and specify the new owner for that database:<\/p>\n<pre class=\"lang:tsql decode:true\">USE YourDatabase\r\nGO\r\n--change YourDatabase owner to 'sa'\r\nEXEC sp_changedbowner 'sa';<\/pre>\n<p>However, as Microsoft states in the sp_changedbowner documentation:<\/p>\n<blockquote><p>This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER AUTHORIZATION instead.<\/p><\/blockquote>\n<h4>The New Way:\u00a0ALTER AUTHORIZATION<\/h4>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/t-sql\/statements\/alter-authorization-transact-sql\" target=\"_blank\" rel=\"noopener\">ALTER AUTHORIZATION<\/a> is the currently preferred way to change the owner of a database. \u00a0It was introduced in SQL Server 2005 (although the docs again say 2008) as a replacement for\u00a0sp_changedbowner, so we really can&#8217;t call it the &#8220;new&#8221; way of doing things since it has been around for over a decade.<\/p>\n<p>As with the previous example, this\u00a0is a pretty straight forward T-SQL command:<\/p>\n<pre class=\"lang:tsql decode:true\">--change YourDatabase owner to 'sa'\r\nALTER AUTHORIZATION ON DATABASE::YourDatabase to sa;<\/pre>\n<p>The nice thing about ALTER AUTHORIZATION is that it can be used to change the ownership of several other things, not just a database. \u00a0Be sure to review the Microsoft docs for a full list with examples.<\/p>\n<p><em>This post is part of an ongoing\u00a0<a href=\"https:\/\/sqlnuggets.com\/blog\/category\/sql-scripts\/\">SQL Scripts<\/a>\u00a0series, in which I list useful queries that I use in my day to day database administration.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes it becomes necessary to change the owner of a database. \u00a0When a database is first created, SQL Server likes to set the owner of that database to the login &#8230;<\/p>\n","protected":false},"author":2,"featured_media":550,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34,52],"tags":[35],"class_list":["post-545","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-sql-scripts","tag-permissions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets\" \/>\n<meta property=\"og:description\" content=\"Sometimes it becomes necessary to change the owner of a database. \u00a0When a database is first created, SQL Server likes to set the owner of that database to the login ...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Nuggets\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-19T14:40:29+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"722\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eric Cobb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cfgears\" \/>\n<meta name=\"twitter:site\" content=\"@sqlnugg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eric Cobb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/\"},\"author\":{\"name\":\"Eric Cobb\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\"},\"headline\":\"SQL Scripts: How To Change The Owner Of A Database\",\"datePublished\":\"2017-09-19T14:40:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/\"},\"wordCount\":402,\"commentCount\":2,\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/private-864304_1280.jpg\",\"keywords\":[\"Permissions\"],\"articleSection\":[\"Security\",\"SQL Scripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/\",\"name\":\"SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/private-864304_1280.jpg\",\"datePublished\":\"2017-09-19T14:40:29+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/private-864304_1280.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/09\\\/private-864304_1280.jpg\",\"width\":1280,\"height\":722},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/sql-scripts-change-owner-database\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Scripts: How To Change The Owner Of A Database\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\",\"name\":\"SQL Nuggets\",\"description\":\"Nuggets Of SQL Server Knowledge\",\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/www.sqlnuggets.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\",\"name\":\"SQL Nuggets\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/website-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/website-logo.jpg\",\"width\":320,\"height\":54,\"caption\":\"SQL Nuggets\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/sqlnugg\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/ericcobb\\\/\"]},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\",\"name\":\"Eric Cobb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"caption\":\"Eric Cobb\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cfgears\"],\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/author\\\/eric-cobb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/","og_locale":"en_US","og_type":"article","og_title":"SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets","og_description":"Sometimes it becomes necessary to change the owner of a database. \u00a0When a database is first created, SQL Server likes to set the owner of that database to the login ...","og_url":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/","og_site_name":"SQL Nuggets","article_published_time":"2017-09-19T14:40:29+00:00","og_image":[{"width":1280,"height":722,"url":"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","type":"image\/jpeg"}],"author":"Eric Cobb","twitter_card":"summary_large_image","twitter_creator":"@cfgears","twitter_site":"@sqlnugg","twitter_misc":{"Written by":"Eric Cobb","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#article","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/"},"author":{"name":"Eric Cobb","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a"},"headline":"SQL Scripts: How To Change The Owner Of A Database","datePublished":"2017-09-19T14:40:29+00:00","mainEntityOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/"},"wordCount":402,"commentCount":2,"publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","keywords":["Permissions"],"articleSection":["Security","SQL Scripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/","url":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/","name":"SQL Scripts: How To Change The Owner Of A Database - SQL Nuggets","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#primaryimage"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","datePublished":"2017-09-19T14:40:29+00:00","breadcrumb":{"@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#primaryimage","url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","contentUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","width":1280,"height":722},{"@type":"BreadcrumbList","@id":"http:\/\/www.sqlnuggets.com\/sql-scripts-change-owner-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.sqlnuggets.com\/"},{"@type":"ListItem","position":2,"name":"SQL Scripts: How To Change The Owner Of A Database"}]},{"@type":"WebSite","@id":"http:\/\/www.sqlnuggets.com\/#website","url":"http:\/\/www.sqlnuggets.com\/","name":"SQL Nuggets","description":"Nuggets Of SQL Server Knowledge","publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.sqlnuggets.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/www.sqlnuggets.com\/#organization","name":"SQL Nuggets","url":"http:\/\/www.sqlnuggets.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/logo\/image\/","url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2023\/11\/website-logo.jpg","contentUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2023\/11\/website-logo.jpg","width":320,"height":54,"caption":"SQL Nuggets"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/sqlnugg","https:\/\/www.linkedin.com\/in\/ericcobb\/"]},{"@type":"Person","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a","name":"Eric Cobb","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","caption":"Eric Cobb"},"sameAs":["https:\/\/x.com\/cfgears"],"url":"https:\/\/sqlnuggets.com\/author\/eric-cobb\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/09\/private-864304_1280.jpg","jetpack_shortlink":"https:\/\/wp.me\/pdyDvE-8N","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1534,"url":"https:\/\/sqlnuggets.com\/setting-the-database-owner-compatibility-level-and-recovery-model-with-powershell\/","url_meta":{"origin":545,"position":0},"title":"Setting The Database Owner, Compatibility Level, And Recovery Model With PowerShell","author":"Eric Cobb","date":"December 30, 2020","format":false,"excerpt":"One of the great things about dbatool is that it allows you to run commands against multiple things. Sometimes you may need to run the same command on every server, or every database on a server, or every database on every server (not recommended). Today we're going to look at\u2026","rel":"","context":"In &quot;Configurations&quot;","block_context":{"text":"Configurations","link":"https:\/\/sqlnuggets.com\/category\/configurations\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/12\/pexels-photo-97077.jpeg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1255,"url":"https:\/\/sqlnuggets.com\/sql-scripts-list-databases-a-login-can-access\/","url_meta":{"origin":545,"position":1},"title":"SQL Scripts: List Databases A Login Can Access","author":"Eric Cobb","date":"January 7, 2020","format":false,"excerpt":"When you are managing your SQL Server database permissions through Active Directory Groups (which you should be!), it can sometimes be difficult to know just which databases a user actually has access to. Sure, you could look up each AD Group that user is a member of and then check\u2026","rel":"","context":"In &quot;Security&quot;","block_context":{"text":"Security","link":"https:\/\/sqlnuggets.com\/category\/security\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2019\/12\/checklist-2470549_1280.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2019\/12\/checklist-2470549_1280.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2019\/12\/checklist-2470549_1280.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2019\/12\/checklist-2470549_1280.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2019\/12\/checklist-2470549_1280.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":775,"url":"https:\/\/sqlnuggets.com\/sql-scripts-how-to-find-a-databases-compatibility-level\/","url_meta":{"origin":545,"position":2},"title":"SQL Scripts: How To Find A Database\u2019s Compatibility Level","author":"Eric Cobb","date":"April 17, 2018","format":false,"excerpt":"One thing that a lot of DBAs, especially Accidental DBAs such as myself, don't seem to realize is that just because a database is sitting on a specific version of SQL Server does not mean that database has all of the features of that SQL Server version enabled.\u00a0 To put\u2026","rel":"","context":"In &quot;DB Engine&quot;","block_context":{"text":"DB Engine","link":"https:\/\/sqlnuggets.com\/category\/db-engine\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/04\/black-and-white-blank-challenge-262488-e1523887336460.jpg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":522,"url":"https:\/\/sqlnuggets.com\/sql-scripts-check-logins-permissions\/","url_meta":{"origin":545,"position":3},"title":"SQL Scripts: How To Check Logins And Permissions","author":"Eric Cobb","date":"August 29, 2017","format":false,"excerpt":"Security and permissions are a big part of a DBA's job, and being able to find out things such as who has elevated login permissions, or when the last time a login was used is important. People sometimes get SQL Server\u00a0\"logins\" and \"users\" confused, or think they are the same\u2026","rel":"","context":"In &quot;Security&quot;","block_context":{"text":"Security","link":"https:\/\/sqlnuggets.com\/category\/security\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/08\/security-265130_1920-e1503945772529.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/08\/security-265130_1920-e1503945772529.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/08\/security-265130_1920-e1503945772529.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/08\/security-265130_1920-e1503945772529.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/08\/security-265130_1920-e1503945772529.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":641,"url":"https:\/\/sqlnuggets.com\/sql-server-permissions-manager\/","url_meta":{"origin":545,"position":4},"title":"SQL Server Permissions Manager","author":"Eric Cobb","date":"November 21, 2017","format":false,"excerpt":"Last week I announced\u00a03 new open source SQL Server projects that I have on GitHub.\u00a0 One of those projects is SQL Server Permissions Manager, and today I would like to discuss it\u00a0in more detail. SQL Server Permissions Manager is a suite of scripts that allows you to take \"snapshots\" of\u2026","rel":"","context":"In &quot;Open Source Projects&quot;","block_context":{"text":"Open Source Projects","link":"https:\/\/sqlnuggets.com\/category\/open-source-projects\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/arrows-1577983_1280-e1511283424596.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/arrows-1577983_1280-e1511283424596.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/arrows-1577983_1280-e1511283424596.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/arrows-1577983_1280-e1511283424596.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1615,"url":"https:\/\/sqlnuggets.com\/yikes-cannot-recover-the-master-database\/","url_meta":{"origin":545,"position":5},"title":"Yikes!  Cannot recover the master database!","author":"Eric Cobb","date":"May 11, 2021","format":false,"excerpt":"Recently, during patching for a 2019 SQL Server, the SQL services refused to start after the patching. It was throwing the following heart attack inducing error: Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. This is\u2026","rel":"","context":"In &quot;Corruption&quot;","block_context":{"text":"Corruption","link":"https:\/\/sqlnuggets.com\/category\/corruption\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/corrupt-147974_1280.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/corrupt-147974_1280.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/corrupt-147974_1280.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/corrupt-147974_1280.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/11\/corrupt-147974_1280.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/comments?post=545"}],"version-history":[{"count":0,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media\/550"}],"wp:attachment":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}