ekolis
ekolis

Reputation: 6796

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?

Upvotes: 0

Views: 1722

Answers (1)

Matt Bowler
Matt Bowler

Reputation: 191

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]

Upvotes: 3

Related Questions