<?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>schema | DBA von Nebenan</title>
	<atom:link href="https://dbavonnebenan.de/tag/schema/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:14:29 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://dbavonnebenan.de/wp-content/uploads/2025/04/cropped-www_logo-32x32.png</url>
	<title>schema | 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>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>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>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>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>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-6c531013 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"><strong>Gabriel, der DBAvonNebenan</strong></p>



<p></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>
		<item>
		<title>SysAdmin Role ignoriert das Default User Schema – Eine verwirrende Fehlersuche</title>
		<link>https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-de/</link>
					<comments>https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-de/#respond</comments>
		
		<dc:creator><![CDATA[Gabriel]]></dc:creator>
		<pubDate>Thu, 08 May 2025 10:13:05 +0000</pubDate>
				<category><![CDATA[TSql]]></category>
		<category><![CDATA[DBO]]></category>
		<category><![CDATA[DE]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SYSADMIN]]></category>
		<guid isPermaLink="false">https://dbavonnebenan.de/?p=434</guid>

					<description><![CDATA[<p>Heute hatte ich wieder einen Fall auf dem Tisch, bei dem eine Fehlermeldung einer Anwendung besagte, dass auf ein Objekt in der SQL Server DB nicht zugegriffen werden kann. Der Hersteller behauptete &#8222;Verbindungsproblem&#8220;, ich sagte &#8222;DB oder zumindest Server-Problem&#8220;, Kunde sagt &#8222;früher hat alles funktioniert&#8220;. Die Extended Events waren schnell aufgesetzt, &#8222;Remote Procedure Call Starting&#8220; [&#8230;]</p>
<p>The post <a href="https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-de/">SysAdmin Role ignoriert das Default User Schema – Eine verwirrende Fehlersuche</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Heute hatte ich wieder einen Fall auf dem Tisch, bei dem eine Fehlermeldung einer Anwendung besagte, dass auf ein Objekt in der SQL Server DB nicht zugegriffen werden kann. Der Hersteller behauptete &#8222;Verbindungsproblem&#8220;, ich sagte &#8222;DB oder zumindest Server-Problem&#8220;, Kunde sagt &#8222;früher hat alles funktioniert&#8220;.</p>



<p>Die Extended Events waren schnell aufgesetzt, &#8222;Remote Procedure Call Starting&#8220; zeigt mir ein Statement ohne vollqualifizierten Tabellennamen. Das Zielobjekt liegt in der Database unter dem db_owner Schema. Najaaa, das ist schon fragwürdig, aber OK. Warum nicht als dbo belassen?</p>



<p>Jedenfalls war mir das Verhalten an diesem Punkt wirklich unverständlich, da alles korrekt konfiguriert war: Default Schema des Users, db_owner auf der DB. Und der SysAdmin. Das war mir aufgefallen, aber nun ja, Entscheidung des Kunden. Sowas notiere ich mir in einer Session, ändere aber nichts, um gewachsene Abhängigkeiten nicht zu gefährden.</p>



<p>Nach langem Suchen gab ich fast auf, verwies an den Vendor und beendete den Call. Leider kann ich solche Sachen nicht loslassen, also feuerte ich das Lab an, baute die Umgebung nach und siehe da, fand den Fehler.</p>



<p>Das Problem ist die SysAdmin-Rolle. Sie mappt den Login direkt auf den dbo-User der Database &#8211; egal ob der eigentliche User existiert oder nicht, erbt somit das Default Schema von dbo. Mindblowing, wusste ich nicht. 🙂</p>



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



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



<figure class="wp-block-image size-full is-resized has-custom-border"><img loading="lazy" 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="auto, (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 aktiv</h2>



<figure class="wp-block-image size-full is-resized has-custom-border"><img loading="lazy" 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="auto, (max-width: 667px) 100vw, 667px" /></figure>



<figure class="wp-block-image size-large is-resized has-custom-border"><img loading="lazy" 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="auto, (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 für die 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-6c531013 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>Verwende immer vollqualifizierte Objektnamen, irgendwann wirst du froh sein, dass du es getan hast. Das kannst du in vielen Blogs lesen.</li>



<li>Arbeite immer nach POLP (<a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">Principle of Least Privilege</a>), ein App-User sollte keine SysAdmin-Rechte haben! 🙂</li>
</ul>
</div>



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



<p></p><p>The post <a href="https://dbavonnebenan.de/sql-server-sysadmin-role-can-override-the-default-schema-de/">SysAdmin Role ignoriert das Default User Schema – Eine verwirrende Fehlersuche</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-de/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
