One of my clients was deploying SharePoint and they were following some documents to make sure it is as per their standard deployment. They were seeing below error while updating the login from dbo to some other login from user mapping window (for login properties window). Let us learn how to fix error 15150 about cannot alter the user.
Rename failed for User ‘dbo’. (Microsoft.SqlServer.Smo)
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
Cannot alter the user ‘dbo’. (Microsoft SQL Server, Error: 15150)
When I ran on script option, here was the output
USE [DBODB] GO ALTER USER [dbo] WITH NAME=[DB1] GO
WORKAROUND/SOLUTION
To fix this issue we need to change the default owner to ‘sa’
Use <database_name> GO sp_changedbowner 'sa' GO
Well, this looks very simple but indeed a very crucial blog. I see this error every single day with my customer and today I decided to write a blog post about it.
There are a few other blogs related to this blog post are listed here:
- SQL SERVER – Forgot the Password of Username SA
- SQL SERVER – Change Password of SA Login Using Management Studio
- SQL SERVER – Fix – Login failed for user ‘username’. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
Reference: Pinal Dave (https://blog.sqlauthority.com)
10 Comments. Leave new
“sp_changedbowner ‘sa'”
That’s from the dark ages, and indeed is deprecated. Do it like this instead:
ALTER AUTHORIZATION ON DATABASE:: TO sa;
John
Agreed.
Thank you
Nice.
Once again Mr. Dave, you make me look smart!
This solution worked for me as well. Thanks a lot Mr. Dave, you always have a solution for every SQL issue!!!
This solution is not working for me and still getting same error Cannot alter the user dbo
Ran into this same issue today and this tip really saved my bacon. Thanks again Dave!
This solution is not working for me and still getting same error Cannot alter the user dbo