SQL Server master user lost his permissions unexpectedly. When I try to access my database tables, I get the following error on SSMS:
The SELECT permissi
I was able to solve my problem after contacting AWS support.
CAUSE
The cause of my problem was that db_denydatawriter and db_denydatareader were granted to master user mistakenly.
So, master user does not have read/write permissions on your database, when trying to grant or revoke permissions on SSMS the User Mapping will not be able to list the database because SSMS can't read the properties anymore and will show the error:
One or more databases are inaccessible and will not be displayed in list
To check if you have granted db_denydatawriter or db_denydatareader to your master user, try the folloing command:
use [YourDatabaseName]
go
sp_helpuser
Changing master password won't help because that will grant db_owner permission but it won't remove the Deny permission.
SOLUTION
Use the following command to remove the Deny permission:
USE [database-name]
GO
ALTER ROLE [db_denydatareader] DROP MEMBER [master-user-name]
GO
ALTER ROLE [db_denydatawriter] DROP MEMBER [master-user-name]
GO
It worked for me, hope it helps!