Error 15138 Ms Sql
Contents |
| Related Tips: More > Security Problem Recently I had an issue while dropping an orphaned user for an obsolete login. I was unable to drop the user and it failed with the below error messages. Msg 15421, Level 16, State 1,
Microsoft Sql Server 2012 Error 15138
Line 1 The database principal owns a database role and cannot be dropped. Msg 15138, Level 16, error 15138 sql server 2008 State 1, Line 1 The database principal owns a schema in the database, and cannot be dropped. Solution In this article I will explain what mssql 15138 needs to be done prior to dropping the user if it failed with error message 15421 or error message 15138. As per Microsoft SQL Security you cannot drop a user in one of the below scenarios: Database Principal/User owns a database role
Microsoft Sql Server Error 15138
Database Principal/User owns a schema To learn more about orphaned users take a look at this tip Understanding and dealing with orphaned users in a SQL Server database. Query to Get Database Roles Owned by a User You can run this script to get a list of database roles owned by a particular user. Just substitute the orphaned user name where I have "Jugal". -- Query to get the user associated Database Role select DBPrincipal_2.name as role, DBPrincipal_1.name as owner from sys.database_principals as DBPrincipal_1
Remove User From Schema Sql Server
inner join sys.database_principals as DBPrincipal_2 on DBPrincipal_1.principal_id = DBPrincipal_2.owning_principal_id where DBPrincipal_1.name = 'Jugal' Query to Get Database Schemas Owned by a User You can run this script to get a list of schemas owned by a particular user. Just substitute the orphaned user name where I have "Dj". -- Query to get the user associated schema select * from information_schema.schemata where schema_owner = 'Dj' As a next step to fix the issue we will transfer the ownership of the database role or schema to DBO. We can do this using either SSMS or a T-SQL script. Fix Error Msg 15421 Using SSMS to Fix the Error Go to Object Explorer > Connect to the Target Server > Expand the target Database > Expand Security > Expand Roles > Expand Database Roles-> Right Click on the database role that you need to modify. You can see the user name "Jugal" as the owner. Change it to "dbo" or some other user to resolve the error. You can just enter the user and click OK to save the change or click on the "..." to find a user. Using a Script to Fix the Error Here we are transferring ownership of the "db_owner" role to "dbo". --Query to fix the error Msg 15138 USE [db1] GO ALTER AUTHORIZATION ON ROLE::[db_owner] TO [dbo] GO Fix Error Msg 15138 Using SSMS to Fix the Error Go to Object Explorer > Connect to the Target Server > Expand the target Database > Expand Security > Expa
in SQL Server OUTPUT Clause in SQL Server SQL Server Configuration Manager not found in Programs list Set First Day of the Week in SQL the database principal owns a database role and cannot be dropped Server Built-in Logical Function CHOOSE in SQL Server How to Script
The Database Principal Owns A Service In The Database And Cannot Be Dropped
SQL Server Configuration Options How to List all Disabled Indexes in a SQL Server Database How to Disable sql server drop schema and Enable Index in SQL Server SQL Server Buffer Pool Memory used by each Object and each Database SQL Server Views WITH CHECK OPTION See the Default Schema of SQL https://www.mssqltips.com/sqlservertip/2620/steps-to-drop-an-orphan-sql-server-user-when-it-owns-a-schema-or-role/ Server Database Users and Groups How to List all SQL Logins with Passwords not Enforced by Policies How to List all Locked SQL Logins in SQL Server EOMONTH Function to Get First and Last Day of a Month in SQL Server Concatenate SQL Server Columns that contain NULL values How to convert VARCHAR to Integer in SQL Server with CAST http://zarez.net/?p=179 and CONVERT « « » » How to enable and disable trace flags, or check for active trace flags in SQL Server How to drop database user that owns a schema - SQL Server Error: 15138 When you try to remove the user from database which owns a schema in the database you will get the following error: The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138) and you will not be able to remove the user until you change the schema owner. To change the schema owner from Sql Server Management Studio: Expand your database -> Security -> Schemas. In the Object Explorer Details you can see a list of the schemas and the owners: Right click on the schema that is owned by the user you want to delete and change the owner (Properties -> General -> Schema Owner). Query: Run the following query if the user you are trying to drop is named for example ‘my_app_user’ and it exists in the database ‘AW2008’: US
cannot be dropped!! 05 Wednesday Feb 2014 Posted by Subhro Saha in SQL Server: Administration ≈ 1 Comment TagsAlter Authorization, Database Principal, Drop User, Schema, SQL Error 15138, sys.schemas https://subhrosaha.wordpress.com/2014/02/05/sql-server-error-15138-the-database-principal-owns-a-schema-in-the-database-and-schema-cannot-be-dropped/ Today one of my reader asked a question about how to fix the error while trying to remove a login from a database. The reader was getting the below error: http://www.dotnetnukeblog.de/post/Microsoft-SQL-Server-Error-15138-Drop-User-Account.aspx Msg 15138, Level 16, State 1, Line 1The database principal owns a schema in the database, and cannot be dropped. The error message of SQL Server is self explanatory as sql server there were schema associated with the user and we have to transfer those schema before removing the User. In this post I will explain the workaround for this error: Lets assume I am trying to drop a user named "TestUser" from DemoDB database. Now, run the below query in the database from which we are trying to drop the user. Use microsoft sql server DemoDB ;SELECT s.nameFROM sys.schemas sWHERE s.principal_id = USER_ID(‘TestUser') In my test scenario, I got the below result set from the above query: Then, use the names found from the above query below in place of the SchemaName below. And drop your user. ALTER AUTHORIZATION ON SCHEMA::SchemaName TO dbo GODROP USER TestUser In my Test scenario I used the below queries: ALTER AUTHORIZATION ON SCHEMA::db_securityadmin TO dbo;ALTER AUTHORIZATION ON SCHEMA::db_ddladmin TO dbo; GO DROP USER TestUser Hope this helps. Cheers, Subhro Saha Subhro's BlogGoogle Related Post navigation ← Previous post Next post → 1 thought on “SQL Server: Error: 15138-The database principal owns a schema in the database, and schema cannot be dropped!!” Pingback: How To Fix Error 15138 Sql Server Errors - Windows Vista, Windows 7 & 8 Leave a Reply Cancel reply Enter your comment here... Fill in your details below or click an icon to log in: Email (Address never made public) Name Website You are commenting using your WordPress.com account. (LogOut/Change) You are commenting using your Twitter account. (LogOut/Change) You are commenting using your Facebook account. (LogOut/Change) You are commenting using your Google+ account. (LogO
den Mircosoft SQL Express 2008 eingespielt. Dabei wollte ich ein wenig aufräumen und die nicht benötigten Benutzerkonten löschen. Jedoch habe ich bei dem Versuch immer die Fehlermeldung"The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)." bekommen. Die Lösung für dieses Problem ist recht einfach: Wenn für den Benutzeraccount ein Schema angelegt wurde, muss zunächst das Schema aus der SQL Server Datenbank entfernt werden. Um zu überprüfen, ob es ein Schema für den Benutzer gibt, kann man mit dem SQL Server Manager bei der entsprechenden Datenbank unter Sicherheit => Schema nachschauen. Wenn kein Schema mehr von diesem Benutzer existiert, lässt sich auch das Benutzerkonto ohne Fehlermeldung löschen. Datum: Juni 22, 2011 22:16 Tags: Kategorien: SQL Server Submit to DotNetKicks... 0Kommentare Ähnliche BeiträgeSQL 2005 Server error: Property IsLocked is not available for Login '[username]' Heute musste ich feststellen das auf einem Windows 2003 Server mit einer Instance vomMS SQL Se...Microsoft SQL Server 2005 für verschiedene KundensegmenteDie neue Version des MS SQL Servers wird für verschiedene Anforderungen der Kunden verfügbar sein. M...XML in SQL Server 2005Microsoft bietet in den nächsten Tagen mal wieder eine Reihe von Webcast zum Thema MS SQL Server 200... Kommentar schreiben Name* E-Mail* Webseite Kommentar* Benachrichtige mich bei neuen Kommentaren Antwort auf Kommentar abbrechen 5+5 = The captcha value you provided is incorrect. Wichtige Seiten...DatenschutzhinweiseExample pageImpressumWer bin ich Search Tag cloudArchiv 2013 Februar (2) 2012 Dezember (1)November (2)Juli (1) 2011 November (2)Oktober (2)August (1)Juli (1)Juni (1)März (3)Januar (5) 2010 Dezember (1)Oktober (3)September (4)Juli (1)Juni (1)April (4)März (2)Februar (2)Januar (1) 2009 November (1)Oktober (1)September (2)August (1)Juli (4)Juni (2)Mai (4)April (2)März (2)Februar (1)Januar (2) 2008 November (2)Oktober (5)September (1)August (3)Juli (3)Juni (2)Mai (3)April (3)März (1)Februar (4)Januar (4) 2007 Dezember (3)November (1)September (6)August (2)Juli (5)Mai (4)April (5)Februar (2)Januar (5) 2006 Dezember (6)November (7)Oktober (5)September (5)August (3)Juli (4)Juni (5)Mai (4)April (4)Februar (4)Januar (7) 2005 Dezember (6)November (9)Oktober (5)September (4)August (8)Juli (13)J