troubleshoot microsoft sql server error 15183
TRANSCRIPT
![Page 1: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/1.jpg)
FIX MS SQL SERVER ERROR: 15138
![Page 2: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/2.jpg)
TABLE OF CONTENTS
1. What is the error 15138 in SQL Server?
2. Resolution
3. Resolution using SSMS
4. Resolution using T-SQL
5. Conclusion
![Page 3: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/3.jpg)
WHAT IS SQL ERROR: 15138?Error 15138 defined itself. It tells, that the database user which you are trying to drop is the database schema owner.
Msg 15138 Level 16, State 1, Line 1“The database principal owns a schema in the database, and can not be dropped.”
![Page 4: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/4.jpg)
RESOLUTION
There are two methods of changing the owner of the schema of the database. These are given as following:
1. Using T-SQL
2. Using SSMS
![Page 5: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/5.jpg)
USING SSMS
First of all, open the database engine having valid credentials.
Expand the Databases > select the desired database which you want to change the schema owner.
![Page 6: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/6.jpg)
1. Go to the security of database > right click >select properties option.
![Page 7: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/7.jpg)
2. A window will appear named as Schema Properties and INFORMATION_SCHEMA. Click on the search button to find the schema owner to drop.
![Page 8: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/8.jpg)
3. Now a new window will open named as Search Roles and Users, enter the schema name or browse the object to change the owner now select the schema and click OK to drop the particular schema.
![Page 9: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/9.jpg)
USING T-SQL
For the deletion of Orphaned users in SQL Server Using T-SQL follow given steps:
Detect Orphaned Users in Database Relink the Server Login Account Alter the Logins of Orphaned Users
![Page 10: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/10.jpg)
To drop the user you need to find the assigned schema of users in database to find the orphaned users run the given following query.
USE database_name;
GO;
sp_change_users_login @Action='Report';
GO;
1. Detect Orphaned User in Database
![Page 11: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/11.jpg)
Relink the server login account by login name with the database user using database_user.
USE
database_name;
GO
sp_change_users_login @Action=‘update_one’,
@UserNamePattern='database_user',
@LoginName=‘login_name';
GO
2. Relink the Server Login Account
![Page 12: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/12.jpg)
Now user can alter the password of the login_name login account using sp_password SP, like this-
USE master
GO
sp_password @old=NULL, @new='password',
@loginame='login_name‘
GO
3. Alter the Logins of Orphaned Users
![Page 13: Troubleshoot Microsoft SQL Server Error 15183](https://reader033.vdocument.in/reader033/viewer/2022061615/58813c1a1a28abf65a8b5561/html5/thumbnails/13.jpg)
CONCLUSIONIn this presentation you can see that how can we change the owner of orphaned schema. We can change the owner using SSMS and T-SQL Statements, which are described here step by step.
To know more go through-