views:

46

answers:

2

I have a database that I need to connect to and select from. I have an SQL Login, let's call it myusername. When I use the following, no SELECT permission shows up:

SELECT * FROM fn_my_permissions ('dbo.mytable', 'OBJECT')
GO

Several times I tried things like:

USE mydatabase
GO

GRANT SELECT TO myusername
GO

GRANT SELECT ON DATABASE::mydatabase TO myusername
GO

GRANT SELECT ON mytable TO myusername
GO

It says the queries execute successfully, but there is never any difference in the first query. What simple thing am I missing to grant database level select permissions.

As a note, I made double sure it was the correct user, correct database, and I have already tried granting table level select permissions. So far I keep getting the error:

SELECT permission denied on object 'mytable', database 'mydatabase', schema 'dbo'.

Any ideas what I'm missing? Thanks in advance.

EDIT/UPDATE:

Upon right clicking the SQL User in SQL Server Management Studio 2008, I discovered every single Database role is checked, including db_denydatareader and db_datareader... might this be blocking my ability to grant permission at the database level? If this is so, what is the purpose of db_denydatareader? It seems silly to me to have a 'DENY' that can't be viewed when querying permissions.

SUMMARY: Sure enough, that fixed it.

A: 

Have you tried reconnecting with that SQL user account?

ajdams
+1  A: 

In SSMS - under Databases-->mydatabase-->Security-->Users-->myusername, right click the username, select properties. Under database role membership, make sure db_denydatareader is not checked as this will override whatever permissions you had granted.

Knew it was something simple. :)

Brandi