Skip to content
Advertisement

sa can’t ALTER USER in SQL Server

I’m trying to run an alter user command as sa in SQL Server:

ALTER USER MyAppDemoAdmin2 WITH LOGIN = MyAppDemoAdmin2

However when I do so I get this error:

Msg 15151, Level 16, State 1, Line 1
Cannot alter the user ‘MyAppDemoAdmin2’, because it does not exist or you do not have permission.

I see that the user does exist in the user list, so I must not have permission – but I’m logged in as sa! How is that possible? How can I get permission to alter the user?

Advertisement

Answer

Users are database specific, you will need to be in the correct database context to alter the user. Check which context you are in by:

SELECT DB_NAME()

Change your context to the appropriate database with:

USE [database]
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement