<?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>Drop Login Failed - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/drop-login-failed/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Mon, 14 May 2018 15:30:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>Drop Login Failed - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 21 Aug 2017 20:00:40 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=572</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15433 during fixing orphaned users on a SQL Server Instance where AlwaysON Availability Group was configured. Our application was facing connectivity issue post AOAG failover and not able to connect to database whereas everything&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/">Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15433 during fixing orphaned users on a SQL Server Instance where <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysON Availability Group</a> was configured. Our application was facing <a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">connectivity issue post AOAG failover</a> and not able to connect to database whereas everything was working fine from database end. Databases were successfully <a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">transitioning their roles during failover</a>.</p>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</strong></span></h3>
<p>I have an AOAG configuration having two replicas in my environment which is set for Automatic failover. Last week, we had High Availability testing for all applications. Issue occurred when application team tried to connect to database server after failover. They were <a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">failed to connect to the secondary replica</a> using Listener after failover whereas applications were working fine from primary replica. Issue came because SQL login which was used by application has different sid on secondary replica than the primary replica.</p>
<p>During fixing above issue, we came across an error about which we will be discussing in this post. One of the engineer has accidently created a wrong login with the same SID that we were about to use to create the application login to fix above issue. When we have tried to create application login we get below error.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Msg 15433, level 16, State 1, Line 1,</span></div>
<div class="codediv"><span class="kwrd" style="color: red;">Supplied parameter sid is in use.</span></div>
<p>Here i will explain step by step method to fix this SQL Server Error 15433.</p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>Here i will reproduce this issue and then fix it in a step by step manner. So, final objective is to create a login with same name, password &amp; sid on secondary replica to sync the login details of associated application. Let us first check the login sid of identified login on primary replica. Run below code to get it.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT name, SID, createdate from syslogins
WHERE name='xyz'</strong></span></pre>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-573" src="http://techyaz.com/wp-content/uploads/2017/08/1.jpg" alt="" width="601" height="164" srcset="https://techyaz.com/wp-content/uploads/2017/08/1.jpg 601w, https://techyaz.com/wp-content/uploads/2017/08/1-300x82.jpg 300w" sizes="(max-width: 601px) 100vw, 601px" /></p>
<p>Copy the SID of this login from above screen for further uses. Now connect to secondary replica and run below command to create same login with same password &amp; sid. You can remove Check_Policy option if your login has password policy applied.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>CREATE Login xyz WITH password = 'techy@z@123', Check_Policy=off, SID = 0x03981anjkhdvehh73964jbdbj783</strong></span></pre>
<p><img decoding="async" class="aligncenter size-full wp-image-574" src="http://techyaz.com/wp-content/uploads/2017/08/2.jpg" alt="" width="514" height="96" srcset="https://techyaz.com/wp-content/uploads/2017/08/2.jpg 514w, https://techyaz.com/wp-content/uploads/2017/08/2-300x56.jpg 300w" sizes="(max-width: 514px) 100vw, 514px" /></p>
<p>Here we got the issue because someone has already created another login with same SID. Now our next step is to check that login which was created with this SID. Run below command on secondary replica to get this done.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT name, SID, createdate from sysloginswhere SID = 0x0398manjkhdvehh73964jbdbj783</strong></span></pre>
<p><img decoding="async" class="aligncenter size-full wp-image-575" src="http://techyaz.com/wp-content/uploads/2017/08/3.jpg" alt="" width="519" height="114" srcset="https://techyaz.com/wp-content/uploads/2017/08/3.jpg 519w, https://techyaz.com/wp-content/uploads/2017/08/3-300x66.jpg 300w" sizes="(max-width: 519px) 100vw, 519px" /></p>
<p>We can see the login name which was created under given SID. We have to created application login with same SID to establish application connectivity to database after failover so we will drop this Login and recreate application login with this SID. Later we can create deleted login which will have different SID. If not needed you should not create unwanted logins on SQL Server. Run below command to drop this login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: green;"><strong>--Change login name with login.</strong></span><strong><span class="kwrd" style="color: blue;">
DROP Login login</span></strong></pre>
<p>SSMS way to drop a login is given in below steps:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-576" src="http://techyaz.com/wp-content/uploads/2017/08/4.jpg" alt="" width="446" height="121" srcset="https://techyaz.com/wp-content/uploads/2017/08/4.jpg 446w, https://techyaz.com/wp-content/uploads/2017/08/4-300x81.jpg 300w" sizes="auto, (max-width: 446px) 100vw, 446px" /></p>
<p>You might get multiple dependency errors during dropping this login because there is possibility this login might own few objects, agent jobs or databases on this instance if it was created long before. You can read below articles to fix such kind of issues if you will face any.</p>
<ul>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix  Error 15173: Revoke the permissions before dropping the login.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">Fixing error 15138 &amp; Error 3729: DROP login failed</a></li>
<li><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">How to fix error 15170: Login owns one or more SQL Agent Jobs.</a></li>
</ul>
<p>Now once this login will be dropped, you will be able to create your application login with required SID. You can see that in below screen.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>CREATE Login xyz WITH password = 'techy@z@123', Check_Policy=off, SID = 0x03981anjkhdvehh73964jbdbj783</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-577" src="http://techyaz.com/wp-content/uploads/2017/08/5.jpg" alt="" width="740" height="139" srcset="https://techyaz.com/wp-content/uploads/2017/08/5.jpg 740w, https://techyaz.com/wp-content/uploads/2017/08/5-300x56.jpg 300w" sizes="auto, (max-width: 740px) 100vw, 740px" /></p>
<p>We can see command executed successfully. Now issue is fixed here.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/">Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15170: Login owns one or more Agent Jobs</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 18:33:45 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=545</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15170 while removing a SQL Server login on one of SQL Server Instance. Microsoft SQL Server Error 15170 suggests that the login which i want to drop owns one or more SQL Server Agent jobs. Here&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/">Fix SQL Server Error 15170: Login owns one or more Agent Jobs</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15170 while removing a SQL Server login on one of SQL Server Instance. Microsoft SQL Server Error 15170 suggests that the login which i want to drop owns one or more SQL Server Agent jobs. Here we will fix this issue by changing the owner of all identified jobs and then will drop the SQL login.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
</ul>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15170</strong></span></h3>
<p>I had to remove a SQL login on one of SQL Server instance where <strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> </strong>is configured and running. We need to remove this login and recreate it with the same SID which are present on primary replica to fix an<span style="color: #0000ff;"><strong><a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener"> AOAG Automatic failover issue</a>.</strong></span> Login was failed to drop because of SQL Server error 15170 which suggests that this login owns one or more SQL Server Agent jobs. Error details are given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;"><strong>Drop failed for Login &#8220;xyz&#8221;</strong><br />
<strong> The login is the owner of 3 job(s). You must delete or reassign these jobs before the login can be dropped. (Microsoft SQL Server, Error:15170)</strong><br />
</span></div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-546" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15170.jpg" alt="error 15170" width="713" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15170.jpg 713w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15170-300x267.jpg 300w" sizes="auto, (max-width: 713px) 100vw, 713px" /></p>
<p>As error clearly says, that one or more Agent jobs are owned by this login so let us check the details about it. Expand <strong>SQL Server Agent</strong> followed by <strong>Jobs</strong> folder of your SQL Server Instance connected in SSMS. You can see below jobs were there on SQL Server Instance.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-547" src="http://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs.jpg" alt="agent jobs" width="471" height="215" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs.jpg 471w, https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs-300x137.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs-980x450.jpg 980w" sizes="auto, (max-width: 471px) 100vw, 471px" /></p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>Now check the properties of these agent jobs to check the job owner. Double click on identified agent job. You will get below image. Here you can see job owner is showing as same account which we are trying to drop. Change it to sa and click on ok button to apply the change. Repeat the same to the all three agent jobs.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-548" src="http://techyaz.com/wp-content/uploads/2017/08/3-job-owner.jpg" alt="job owner" width="709" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-job-owner.jpg 709w, https://techyaz.com/wp-content/uploads/2017/08/3-job-owner-300x269.jpg 300w" sizes="auto, (max-width: 709px) 100vw, 709px" /></p>
<p>Now owner of agent jobs is changed to sa. Next step is to go ahead and drop the login again. you can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>This time your login will be dropped successfully. If you are still facing some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
</ul>
<p>Here, we have fixed Microsoft SQL Server error 15170. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/">Fix SQL Server Error 15170: Login owns one or more Agent Jobs</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 10 Aug 2017 11:24:35 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=419</guid>

					<description><![CDATA[<p>Generally, Microsoft SQL Server error 15434 appears during removing a SQL Server login. This error generates when you try to drop a login that has an active open connection to SQL Server Instance. Here i will discuss all the aspects&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/">Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Generally, Microsoft SQL Server error 15434 appears during removing a SQL Server login. This error generates when you try to drop a login that has an active open connection to SQL Server Instance. Here i will discuss all the aspects of this error and the its resolution.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix Error 15141: Server principal owns one or more endpoints.</a></strong></li>
</ul>
<h3><span style="color: #333399;"><strong>Microsoft SQL Server Error 15434</strong></span></h3>
<p>This error generates when a login has made a connection to the SQL Server Instance and you are trying to drop the same login. Solution to fix this issue is to close all sessions which are opened by this login and then drop it. You can get the details about the sessions which are open using this login id either by sp_who2 or by DMV sys.dm_exec_sessions.</p>
<p>I had to remove a domain login on one of SQL Server instance but login was failed to drop because of SQL Server error 15434 which suggests that the login is currently logged in. Error details are given below.</p>
<p><span class="kwrd" style="color: red;">Drop failed for Login &#8220;domain\abc&#8221;<br />
Could not drop login &#8216;domain\abc&#8217; as the user is currently logged in. (Microsoft SQL Server, Error: 15434)<br />
</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-421" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15434.jpg" alt="error 15434" width="703" height="625" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15434.jpg 703w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15434-300x267.jpg 300w" sizes="auto, (max-width: 703px) 100vw, 703px" /></p>
<p>As error clearly says that above login is currently logged in. Run below T-SQL code to get the details about the sessions or connections this login has made to the SQL Server Instance.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;">SELECT login_name, * FROM sys.dm_exec_sessions
WHERE login_name = 'xyz\abc'
Go
</span></strong></pre>
<p>You will see the details for this login along with the session id in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-422" src="http://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-1024x181.png" alt="get the spid" width="1024" height="181" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-1024x181.png 1024w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-300x53.png 300w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-768x136.png 768w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID.png 1074w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h3><span style="color: #333399;"><strong>Solution</strong></span></h3>
<p>Now we have identified the session id which are running using this login id which we want to drop. Now next step is to kill this session. Make sure to check the SQL code running behind this session id. If it is not critical go ahead and drop the login or if any DML or other operations are running about which you are not aware of, please contact application owners to get the details about this session id. <strong>Don&#8217;t kill any session id that you are not aware of.</strong> Now go ahead and kill above session which is running using our login id. I am going ahead to kill this session because i know what is running under this session which is not critical.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: green;">--Replace the session id 53 with your session id.</span><span class="kwrd" style="color: #0000ff;">
Kill 53
GO
</span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-423" src="http://techyaz.com/wp-content/uploads/2017/08/3-kill-process.jpg" alt="kill process" width="431" height="131" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-kill-process.jpg 431w, https://techyaz.com/wp-content/uploads/2017/08/3-kill-process-300x91.jpg 300w" sizes="auto, (max-width: 431px) 100vw, 431px" /><br />
We can see command executed successfully. You can recheck whether this session is still open or not by executing same command which we have executed in first section.<br />
<img loading="lazy" decoding="async" class="aligncenter size-large wp-image-424" src="http://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-1024x196.jpg" alt="recheck processes" width="1024" height="196" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-1024x196.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-300x57.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-768x147.jpg 768w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes.jpg 1081w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><br />
We can see, session id 53 is no more active and disappeared from the SQL Server transactions. Next step is go ahead and drop the login again. This time your login will be dropped successfully.</p>
<p>If you are still facing same issue during dropping the login and get this error again then you can check SQL Server services log on accounts. Sometimes if you run SQL Server services using the account which you want to drop throws same error. If this is the case then your next step is to change the logon account to some other domain account to release this login. You can see this in below image. Change the log on account of all SQL Server services if they are running using this account. Once you made the changes to the services, restart SQL Server service to bring new account in use by SQL Server.<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-425 size-full" src="http://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215.jpg" alt="check service accounts" width="423" height="481" srcset="https://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215.jpg 423w, https://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215-264x300.jpg 264w" sizes="auto, (max-width: 423px) 100vw, 423px" /><br />
Now go ahead and drop the account again. This time it will work and your login will be removed. You will not face Microsoft SQL Server Error 15434 anymore. You can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>If you are getting some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix Error 15141: Server principal owns one or more endpoints.</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/">Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 09 Aug 2017 07:51:58 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=411</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15141 while removing a SQL Server domain login on one of instance where AlwaysOn is configured. SQL Server Error 15141 suggests that the login which i want to drop owns AlwaysON endpoints. Here we&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/">Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15141 while removing a SQL Server domain login on one of instance where AlwaysOn is configured. SQL Server Error 15141 suggests that the login which i want to drop owns AlwaysON endpoints. Here we will fix this issue by changing the owner of endpoint and then will drop the identified domain login.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></li>
</ul>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15141</strong></span></h3>
<p>I had to remove a domain login on one of SQL Server instance where AlwaysOn is configured and running. Login was failed to drop because of Microsoft SQL Server error 15141 which suggests that this login owns one or more endpoints. Error details are given below:<br />
<span class="kwrd" style="color: red;"><br />
Drop failed for Login &#8220;Login Name&#8221;<br />
The server principal owns one or more endpoint(s) and cannot be dropped. (Microsoft SQL Server, Error:15141)<br />
</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-412" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15141.jpg" alt="error 15141" width="713" height="633" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15141.jpg 713w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15141-300x266.jpg 300w" sizes="auto, (max-width: 713px) 100vw, 713px" /></p>
<p>As error clearly says that one or more endpoints are owned by this login so let us check the details about endpoints. Run below T-SQL code to get the details of endpoint.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;">SELECT n.name, a.*  FROM sys.endpoints a
inner join sys.server_principals n on a.principal_id=n.principal_id
Go
</span></strong></pre>
<p>You will see the endpoint details in below screenshot along with the login id who owns the endpoint. I have blured it because of privacy.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-413" src="http://techyaz.com/wp-content/uploads/2017/08/2-check-details.jpg" alt="check endpoint ownership" width="986" height="307" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-check-details.jpg 986w, https://techyaz.com/wp-content/uploads/2017/08/2-check-details-300x93.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-check-details-768x239.jpg 768w" sizes="auto, (max-width: 986px) 100vw, 986px" /></p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>As we can see that endpoint is owned by this login so now we will change the owner of this endpoint to break the dependency which are the main reason behind this SQl Server error 15141. Now next step is to change the owner to some another login. You can also transfer the ownership to system account sa.</p>
<p>We will use ALTER Authorization statement to transfer ownership of this endpoint from existing server level login to some another server level login. We can not set the ownership to database level users. ALTER AUTHORIZATION can be used to change the ownership of any entity that has an owner. Run below command to change the owner of above endpoint to a login Domain\abc5.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Replace the login id [Domain\abc5] with your login.</span><span class="kwrd" style="color: #0000ff;">
ALTER Authorization on endpoint::Hadr_endpoint to [Domain\abc5]
GO
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-414" src="http://techyaz.com/wp-content/uploads/2017/08/3-change-owner.jpg" alt="transfer ownership to another login" width="633" height="131" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-change-owner.jpg 633w, https://techyaz.com/wp-content/uploads/2017/08/3-change-owner-300x62.jpg 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /><br />
We can see command executed successfully. You can recheck the ownership by executing same command which we have executed in first section. Once change is done. next step is to drop the login.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-415" src="http://techyaz.com/wp-content/uploads/2017/08/4-check-details.jpg" alt="recheck endpoint ownership" width="979" height="235" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-check-details.jpg 979w, https://techyaz.com/wp-content/uploads/2017/08/4-check-details-300x72.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-check-details-768x184.jpg 768w" sizes="auto, (max-width: 979px) 100vw, 979px" /><br />
We can see, now ownership of this endpoint is set to another login. Next step is go ahead and drop the login again. you can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>This time your login will be dropped successfully. If you are still facing some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/">Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 04 Aug 2017 12:02:15 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=391</guid>

					<description><![CDATA[<p>Here we will learn how to fix Microsoft SQL Server error 15138 &#38; error 3729 that we receive while dropping a database user and a schema in SQL Server.  Let us check the details to fix this issue one after&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/">Fix SQL Server Error 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Here we will learn how to fix Microsoft SQL Server error 15138 &amp; error 3729 that we receive while dropping a database user and a schema in SQL Server.  Let us check the details to fix this issue one after another.</p>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 15138</strong></span></h3>
<p>I have discussed similar type of issue in my last tip, where a server level login was owner of some databases which causes to <a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">fail the login removal and throws error 15174</a>. We changed the ownership and then tried to drop that login and it was successful.</p>
<p>Microsoft SQL Server Error 15138 which i am discussing in this tip is also similar kind of error. Here, user has owned some schemas at database level. We will do the same thing, we will change the owner of identified schema and drop the user.</p>
<p>The details of SQL Server error 15138 is given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Drop failed for User &#8216;xyz&#8217;.<br />
The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error:15138)</span></div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-392" src="http://techyaz.com/wp-content/uploads/2017/08/error-15138.png" alt="error 15138" width="618" height="268" srcset="https://techyaz.com/wp-content/uploads/2017/08/error-15138.png 618w, https://techyaz.com/wp-content/uploads/2017/08/error-15138-300x130.png 300w" sizes="auto, (max-width: 618px) 100vw, 618px" /></p>
<p>As error clearly says that a schema is owned by this user in the database so let us check the schema that is owned by this user. Please follow the below process to check the owned schema for an user in the database.</p>
<ul>
<li>Connect to SQL Server Instance in SSMS.</li>
<li>Expand the database folder followed by the actual database name in which your user exists or created.</li>
<li>Expand Security folder inside your target database followed by the Users folder and double click on the target user which you want to drop.</li>
<li>You can see a section named &#8220;Owned Schemas. Here you can see the schemas that are owned by this user.</li>
</ul>
<p>If you find any schema that is owned by this user in above steps, you need to change the owner from this user to some other user or you can change it to dbo as well. See the below screenshot of the owned schema for a user.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-393" src="http://techyaz.com/wp-content/uploads/2017/08/owned-schema.jpg" alt="owned schema" width="474" height="372" srcset="https://techyaz.com/wp-content/uploads/2017/08/owned-schema.jpg 474w, https://techyaz.com/wp-content/uploads/2017/08/owned-schema-300x235.jpg 300w" sizes="auto, (max-width: 474px) 100vw, 474px" /></p>
<h3><span style="color: #800000;"><strong>Solution</strong></span></h3>
<p>Now we have identified the schema which is owned by this user. Our Next step is to change is owner of the identified schema and then drop the login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;"> --Change DBName with your database name and Schema_Name with your schema name which is owned by this user.</span>
<span class="kwrd" style="color: blue;">USE [DBName] </span>
<span class="kwrd" style="color: blue;">G0 </span>
<span class="kwrd" style="color: blue;">Alter Authorization ON Schema::[SCHEMA_NAME] TO [dbo] </span>
<span class="kwrd" style="color: blue;">Go</span></strong></pre>
<p>Once above command will execute, next step is to drop the user again. Run below command to drop the user.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user exists and USERNAME with user name which you want to drop.</span>
<span class="kwrd" style="color: blue;">USE [DBName] </span>
<span class="kwrd" style="color: blue;">Go </span>
<span class="kwrd" style="color: blue;">DROP USER USERNAME </span>
<span class="kwrd" style="color: blue;">Go</span></strong></pre>
<p>This time it will work and user will drop from the database. You can also delete this user from SSMS by right click on the user and choose the delete option. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand Database folder in which user exists.</li>
<li>Expand the Security folder and then Users folder to get the target user name.</li>
<li>Right click and choose delete on the identified user which needs to be deleted.</li>
<li>Click on Ok button of the user deletion window.</li>
</ul>
<p>There are many reasons which causes to fail the user or login deletion. You can find many errors and their solutions in given links. Learn to fix:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Error Code 15173: Revoke the permission(s) before dropping the login.</a></strong></li>
</ul>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 3729</strong></span></h3>
<p>We have seen how to drop an user who was owner of a schema in above section. Now we will understand how to drop a schema that is referenced by an object. If you try to run DROP Schema statement and that particular schema is referenced to some object you will get below error. The details of SQL Server error 3729 is given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Drop failed for Schema &#8216;abc&#8217;.<br />
Cannot drop schema &#8216;abc&#8217; because it is being referenced by object &#8216;Locations&#8217;. (Microsoft SQL Server, Error 3729)</span></div>
<p>In order to fix this issue, we will change the schema of table &#8220;Locations&#8221; to remove the reference. We will use <strong><span style="color: #800000;">sp_changeobjectowner</span></strong> system stored procedure to change schema from abc to dbo. Run below command to change the schema of the table &#8220;Locations&#8221; from abc to dbo.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user/schema/table exists
--Change the abc to your schema name.</span><span class="kwrd" style="color: blue;">
USE DBName
GO
sp_changeobjectowner 'abc.Locations','dbo'
</span></strong></pre>
<p>Now go ahead and drop the schema post executing above command. This time it will drop without an error.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user/schema/table exists
--Change the abc to your schema name which you want to delete.</span><span class="kwrd" style="color: blue;">
USE [DBName]
GO
DROP SCHEMA [abc]
GO
</span></strong></pre>
<p>You can also drop the same using SSMS as well. Go to schema folder inside the security folder of your database. Right click on identified schema and choose delete option.  it will delete your schema.</p>
<p>Learn to fix below errors as well:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Error Code 15173: Revoke the permission(s) before dropping the login.</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="htts://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/">Fix SQL Server Error 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 04 Aug 2017 08:49:49 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=383</guid>

					<description><![CDATA[<p>A login was failed to drop from a SQL Server instance with an error code 15173. As Microsoft SQL Server error 15173 suggests that this login has granted some permissions to other logins. Let us check the details and then&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/">Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A login was failed to drop from a SQL Server instance with an error code 15173. As Microsoft SQL Server error 15173 suggests that this login has granted some permissions to other logins. Let us check the details and then fix this issue so that you can drop such logins without any issue.</p>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 15173</strong></span></h3>
<p>Login was failed to drop because of SQL Server error 15173. This error comes when a login having server level rights has granted permission to any server principal. The details of Microsoft SQL Server error 15173 is given below.</p>
<div class="codediv"><span style="color: #ff0000;">Drop failed for login &#8216;xyz&#8217;.</span><br />
<span style="color: #ff0000;"> Login &#8216;xyz&#8217; has granted one or more permission(s). Revoke the permission(s) before dropping the login. (Microsoft SQL Server, Error:15173)</span></div>
<p><img loading="lazy" decoding="async" class="wp-image-384 alignright" src="http://techyaz.com/wp-content/uploads/2017/08/error-15173-1024x576.jpg" alt="error 15173" width="373" height="210" srcset="https://techyaz.com/wp-content/uploads/2017/08/error-15173-1024x576.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/08/error-15173-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/error-15173-768x432.jpg 768w, https://techyaz.com/wp-content/uploads/2017/08/error-15173.jpg 1280w" sizes="auto, (max-width: 373px) 100vw, 373px" /></p>
<p>You can check the details about the grantee by running below command. You will see the grantee_principal_id and grantor_principal_id column along with other details. Grantor_principal_id will be the id of that login which you want to delete. You can see class_desc and permission_name column to see the permission type and permission category.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span style="color: #0000ff;"><strong>SELECT * FROM sys.server_permissions
Where grantor_principal_id= (Select principal_id from sys.server_principals where name = 'xyz')
</strong></span></pre>
<p>You might get such issues if you have configured AlwaysOn availability group or database mirroring because there might be possibility that your login has granted some permission to endpoint so you need to revoke that permission to fix this issue.</p>
<h3><span style="color: #800000;"><strong>Solution</strong></span></h3>
<p>The solution to fix this issue is to revoke the access which you have granted. Run below command to revoke the access for endpoints. This solution is valid only in case if you have granted access on endpoint. If you have granted access on login then you should keep reading this article.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;"><span style="color: #008000;">--Here xyz was grantor.
--Make sure to revoke the access level which you get in the output of above script. 
--You can get this by focusing on permission_name and state_desc column. In my case, it was view definition and state_desc was GRANT.</span>
USE Master
Go
REVOKE CONNECT ON ENDPOINT:: [hadr_endpoint] TO [xyz]
</span></strong></pre>
<p>Once command will be executed successfully, you are able to drop that login. Do let me know in comment section if you are still facing the issue. You can try below T-SQL to revoke the access from login if you get an output for logins not endpoint.</p>
<p>If this access is assigned to login and not endpoint then you should run below command to revoke the access. Here we are trying to drop login xyz but it was failed because xyz login has granted access to login abc. So, we will revoke the access to drop the user.</p>
<pre><span style="color: #0000ff;"><strong>USE master</strong></span>
<span style="color: #0000ff;"><strong>REVOKE VIEW DEFINITION ON LOGIN:: xyz FROM [abc]</strong></span></pre>
<p>Go ahead and drop the login which you wanted to drop.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;"><span style="color: #0000ff;">--change the name of Login_name with your login name.</span>
<span style="color: #0000ff;">DROP Login 'LOGIN_NAME'
</span></span></strong></pre>
<p>You can also revoke this access level using SSMS/GUI as well. Connect to SQL Server Instance in SSMS, Expand security folder followed by logins folder. Double click on the login and go to securables from left side pane. You can uncheck the permissions allocated to this login and click on ok to apply the changes.</p>
<p>You can click on attached link if you want to learn about another <a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error 15174 which comes during drop Login statement</a>.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/">Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
