<?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>SID &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/sid/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Sun, 25 Sep 2016 20:29:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server: Error 15023 User already exists in current database (Problem of Orphan User)</title>
		<link>https://www.dbrnd.com/2016/11/sql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 12 Nov 2016 16:16:43 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[map sid]]></category>
		<category><![CDATA[orphan user]]></category>
		<category><![CDATA[SID]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3409</guid>

					<description><![CDATA[In this post, I am going to share one of the common error which is faced by most of the SQL Server DBA when they are migrating database from one server to another server. Error 15023: User already exists in the current database. This basically the problem of Orphan users, which exists as a Database [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&amp;linkname=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fsql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user%2F&#038;title=SQL%20Server%3A%20Error%2015023%20User%20already%20exists%20in%20current%20database%20%28Problem%20of%20Orphan%20User%29" data-a2a-url="https://www.dbrnd.com/2016/11/sql-server-error-15023-user-already-exists-in-current-database-problem-of-orphan-user/" data-a2a-title="SQL Server: Error 15023 User already exists in current database (Problem of Orphan User)"></a></p><p>In this post, I am going to share one of the common error which is faced by most of the SQL Server DBA when they are migrating database from one server to another server. </p>
<blockquote><p>Error 15023: User already exists in the current database. This basically the problem of Orphan users, which exists as a Database Login, but no longer exists in Master Database.</p></blockquote>
<p>For example, I have migrated one database and user &#8220;dbrnd&#8221; exists in that database. In that new server, now I am going to create &#8220;dbrnd&#8221; login with assignment of that database.<br />
Which threw an error like user already exists in the current database. </p>
<p>The simple solution is to map SID between Database login and Master Login.<br />
<strong>Step 1: Identified orphaned users of your restored database. </strong></p>
<pre class="crayon-plain-tag">SELECT 
	[dp].[type_desc]
	,[dp].[SID]
	,[dp].[name] AS UserName
FROM sys.database_principals AS dp  
LEFT JOIN sys.server_principals AS sp  
    ON [dp].[SID] = [sp].[SID]
WHERE [sp].[SID] IS NULL  
    AND [dp].[authentication_type_desc] = 'INSTANCE';</pre> </p>
<p><strong>Step 2: Select any of that SID and try to find in sys.sql_logins table. If you do not find any match record, that user is orphaned.</strong></p>
<pre class="crayon-plain-tag">SELECT [sid] 
FROM sys.sql_logins;</pre> </p>
<p><strong>Step 3: Create manual login and map your missing SIDs:</strong></p>
<pre class="crayon-plain-tag">CREATE LOGIN Login4Orphaned 
WITH PASSWORD = 'test123*1',  
SID = 0x088232135A0AAF44A2D1B18DCC280E44;</pre> </p>
<p><strong>Step 4: Now, create user for this and a make your orphaned user as specific user:</strong></p>
<pre class="crayon-plain-tag">ALTER USER MyUser123 WITH Login = Login4Orphaned;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
