troubleshoot microsoft sql server error 15183

13
FIX MS SQL SERVER ERROR: 15138

Upload: jasonclark03

Post on 20-Jan-2017

614 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Troubleshoot Microsoft SQL Server Error 15183

FIX MS SQL SERVER ERROR: 15138

Page 2: Troubleshoot Microsoft SQL Server Error 15183

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

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

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

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

1. Go to the security of database > right click >select properties option.

Page 7: Troubleshoot Microsoft SQL Server Error 15183

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

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

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

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

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

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

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-