Fix SQL error 15138








SQL error 15138 is usually associated with a user who owns a schema possessing database roles.


As part of our Server Support Services, we help numerous customers to resolve sql related issues.


In this Context we shall discuss about how to solve this error.


How to solve SQL error 15138

To solve this sql issue, we can apply 2 different approaches which are through SSMS client or with T-SQL script.


i. Solving SQL error 15138 With SSMS client

Using this method, you should first go to the Object Explorer to connect to the Target Server. Then expand the target database where you will see the Security tab. Next, Expand the security tab and the Schema respectively. Here right click on the schema you intend to to change. In our case our username was "name_of_user". Do change it to "dbo" to fix this error.


ii. To solve SQL error 15138 via T-SQL script

This method is the easiest and it involves transferring ownership of the schema "name_of_user" to "dbo". The following command will do the job;


USE [db1]
GO
 ALTER AUTHORIZATION ON SCHEMA::[name_of_user] TO [dbo]
GO


After successfully executing the above script, then you can proceed with dropping the user without any further issues.


Do you need to fix an SQL issue urgently? Contact us now.



Conclusion

SQL error 15138 occurs when trying to drop an orphaned user from an obsolete login.


For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com