<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>default | DBA von Nebenan</title>
	<atom:link href="https://dbavonnebenan.de/tag/default/feed/" rel="self" type="application/rss+xml" />
	<link>https://dbavonnebenan.de</link>
	<description>Sql Server, Performance &#38; PowerShell Automation</description>
	<lastBuildDate>Sun, 08 Jun 2025 10:13:55 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://dbavonnebenan.de/wp-content/uploads/2025/04/cropped-www_logo-32x32.png</url>
	<title>default | DBA von Nebenan</title>
	<link>https://dbavonnebenan.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SysAdmin Role ignores the Default User Schema &#8211; A confusing story</title>
		<link>https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-en/</link>
					<comments>https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-en/#respond</comments>
		
		<dc:creator><![CDATA[Gabriel]]></dc:creator>
		<pubDate>Thu, 08 May 2025 10:20:44 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[TSql]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[eng]]></category>
		<category><![CDATA[schema]]></category>
		<guid isPermaLink="false">https://dbavonnebenan.de/?p=279</guid>

					<description><![CDATA[<p>Today I had another call on my desk where an error message from an application stated that an object in the Sql Server DB couldn&#8217;t be accessed. The vendor claimed &#8222;connection problem&#8220;, I said &#8222;DB or at least server problem&#8220;, customer says &#8222;everything used to work before&#8220;. The Extended Events were quickly set up, &#8222;Remote [&#8230;]</p>
<p>The post <a href="https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-en/">SysAdmin Role ignores the Default User Schema – A confusing story</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">Today I had another call on my desk where an error message from an application stated that an object in the Sql Server DB couldn&#8217;t be accessed. The vendor claimed &#8222;connection problem&#8220;, I said &#8222;DB or at least server problem&#8220;, customer says &#8222;everything used to work before&#8220;.</p>



<p class="wp-block-paragraph">The Extended Events were quickly set up, &#8222;Remote Procedure Call Starting&#8220; shows me a statement without a fully qualified table name. The target object is in the database under the db_owner schema. Welllll, that&#8217;s already questionable, but OK. Why not keep it as dbo?</p>



<p class="wp-block-paragraph">Anyway, the behavior at this point was really incomprehensible to me since everything was configured correctly: Default schema of the user, db_owner on the DB. And the SysAdmin. I had noticed that, but well, customer&#8217;s decision. I&#8217;ll note things like this in a session, but won&#8217;t change anything to avoid endangering grown dependencies.</p>



<p class="wp-block-paragraph">After searching for a long time, I almost gave up, referred to the vendor and ended the call. Unfortunately, I can&#8217;t let go of stuff like this, so I fired up the lab, rebuilt the environment and lo and behold, found the error. </p>



<p class="wp-block-paragraph">The problem is the SysAdmin role. It directly maps the login to the dbo user of the database &#8211; regardless of whether the actual user exists or not, thus inheriting dbo&#8217;s default schema. Mindblowing, didn&#8217;t know that. 🙂</p>



<div style="height:13px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">SysAdmin Role InActive</h2>



<figure class="wp-block-image size-full is-resized has-custom-border"><img fetchpriority="high" decoding="async" width="655" height="449" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-49_1.png" alt="" class="has-border-color has-base-border-color wp-image-285" style="border-width:1px;width:641px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-49_1.png 655w, https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-49_1-300x206.png 300w" sizes="(max-width: 655px) 100vw, 655px" /></figure>



<div style="height:13px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">SysAdmin Role Active</h2>



<figure class="wp-block-image size-full is-resized has-custom-border"><img decoding="async" width="667" height="351" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-50.png" alt="" class="has-border-color has-base-border-color wp-image-287" style="border-width:1px;width:631px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-50.png 667w, https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-50-300x158.png 300w" sizes="(max-width: 667px) 100vw, 667px" /></figure>



<figure class="wp-block-image size-large is-resized has-custom-border"><img decoding="async" width="504" height="212" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-13.png" alt="" class="has-border-color has-base-border-color wp-image-281" style="border-width:1px;width:495px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-13.png 504w, https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-13-300x126.png 300w" sizes="(max-width: 504px) 100vw, 504px" /></figure>



<div style="height:13px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<div style="height:13px" aria-hidden="true" class="wp-block-spacer"></div>



<details class="wp-block-details is-layout-flow wp-block-details-is-layout-flow"><summary>T-Sql CODE I used for the screenshots</summary><div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
DECLARE @IsSysAdmin INT
SELECT @IsSysAdmin = IS_SRVROLEMEMBER(&#039;sysadmin&#039;)


SELECT SYSTEM_USER AS CurrentLoginName;

SELECT 
    &#039;Current User&#039;  AS Info,
    USER_NAME()     AS Username,
    SCHEMA_NAME()   AS CurrentSchema,
    CASE WHEN @IsSysAdmin = 1 THEN &#039;Yes&#039; ELSE &#039;No&#039; END 
                    AS IsSysAdmin


SELECT 
    &#039;Default Schema&#039;        AS Info,
    dp.name                 AS Username,
    dp.default_schema_name AS DefaultSchema
FROM 
    sys.database_principals dp
WHERE 
    dp.name = USER_NAME()


SELECT 
    &#039;DB Role Membership&#039;    AS Info,
    USER_NAME()             AS Username,
    r.name                  AS RoleName
FROM 
    sys.database_principals u
JOIN 
    sys.database_role_members m ON u.principal_id = m.member_principal_id
JOIN 
    sys.database_principals r ON m.role_principal_id = r.principal_id
WHERE 
    u.name = USER_NAME()

--------------------

-- select * from &#x5B;customSchema].&#x5B;userTable] &lt;&lt;&lt;&lt;&lt; ALWAYS WORKING !!!!!

 select * from &#x5B;userTable]



</pre></div></details>



<div style="height:13px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<div class="wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-461897f4 wp-block-group-is-layout-flex">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="283" height="292" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/2025-05-08_11-43.png" alt="" class="wp-image-284"/></figure>



<ul class="wp-block-list">
<li>Always use fully qualified object names, someday you&#8217;ll be glad you did. You can read this in many blogs.</li>



<li>Always work according to POLP (<a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">Principle of Least Privilege</a>), an app user shouldn&#8217;t have SysAdmin rights! 🙂</li>
</ul>
</div>



<p class="has-text-align-center wp-block-paragraph"><strong>Gabriel, der DBAvonNebenan</strong></p>



<p class="wp-block-paragraph"></p><p>The post <a href="https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-en/">SysAdmin Role ignores the Default User Schema – A confusing story</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-en/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
