简体   繁体   中英

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?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM