The SELECT permission was denied on the object 'Users', database 'XXX', schema 'dbo'

Sql ServerAzure Sql-Database

Sql Server Problem Overview


I moved a database from SQL Server 2012 to Azure. I don't want to use the user master, so I created a user test. This is what I did for database XXX on Azure:

create user test from login test with default_schema=[dbo]
exec sp_addrolemember 'db_owner','test'

I checked, and the database objects I am interested in are all in the schema dbo. The table Users is in the schema dbo.

The connection string in my web project has test as the login. It produces the error message:

The SELECT permission was denied on the object 'Users', database 'XXX', schema 'dbo'

What does the error message mean and what can I do to let user test access the database XXX?

Sql Server Solutions


Solution 1 - Sql Server

  1. Open SQL Management Studio

  2. Expand your database

  3. Expand the "Security" Folder

  4. Expand "Users"

  5. Right click the user (the one that's trying to perform the query) and select Properties.

  6. Select page Membership.

  7. Make sure you uncheck

    db_denydatareader

    db_denydatawriter

enter image description here

This should go without saying, but only grant the permissions to what the user needs. An easy lazy fix is to check db_owner like I have, but this is not the best security practice.

Solution 2 - Sql Server

I think the problem is with the user having deny privileges. This error comes when the user which you have created does not have the sufficient privileges to access your tables in the database. Do grant the privilege to the user in order to get what you want.

GRANT the user specific permissions such as SELECT, INSERT, UPDATE and DELETE on tables in that database.

Solution 3 - Sql Server

The syntax to grant select permission on a specific table :

USE YourDB;

GRANT SELECT ON dbo.functionName TO UserName;

To grant the select permission on all tables in the database:

USE YourDB;

GRANT SELECT TO UserName;

Solution 4 - Sql Server

This is how I was able to solve the problem when I faced it

  1. Start SQL Management Studio.
  2. Expand the Server Node (in the 'Object Explorer').
  3. Expand the Databases Node and then expand the specific Database which you are trying to access using the specific user.
  4. Expand the Users node under the Security node for the database.
  5. Right click the specific user and click 'properties'. You will get a dialog box.
  6. Make sure the user is a member of the db_owner group (please read the comments below before you use go this path) and other required changes using the view. (I used this for 2016. Not sure how the specific dialog look like in other version and hence not being specific)

Solution 5 - Sql Server

Using SSMS, I made sure the user had connect permissions on both the database and ReportServer.

On the specific database being queried, under properties, I mapped their credentials and enabled datareader and public permissions. Also, as others have stated-I made sure there were no denyread/denywrite boxes selected.

I did not want to enable db ownership when for their reports since they only needed to have select permissions.

Solution 6 - Sql Server

Grant permissions for that user is needed

Solution 7 - Sql Server

Check space of your database.this error comes when space increased compare to space given to database.

Solution 8 - Sql Server

I resolve my problem doing this. [IMPORTANT NOTE: It allows escalated (expanded) privileges to the particular account, possibly more than are needed for individual scenario].

  1. Go to 'Object Explorer' of SQL Management Studio.
  2. Expand Security, then Login.
  3. Select the user you are working with, then right click and select Properties Windows.
  4. In Select a Page, Go to Server Roles
  5. Click on sysadmin and save.

Solution 9 - Sql Server

May be your Plesk panel or other panel subscription has been expired....please check subscription End.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOld GeezerView Question on Stackoverflow
Solution 1 - Sql ServerKellen StuartView Answer on Stackoverflow
Solution 2 - Sql ServerRahul TripathiView Answer on Stackoverflow
Solution 3 - Sql ServerJohn HayhowView Answer on Stackoverflow
Solution 4 - Sql ServerPramod B RView Answer on Stackoverflow
Solution 5 - Sql ServerAloha480View Answer on Stackoverflow
Solution 6 - Sql Serverbillah77View Answer on Stackoverflow
Solution 7 - Sql ServerNileshView Answer on Stackoverflow
Solution 8 - Sql ServerccassobView Answer on Stackoverflow
Solution 9 - Sql ServerAbhendra TiwariView Answer on Stackoverflow