Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to give a user ONLY permission to a view, and nothing else in the database


How to give a user ONLY permission to a view, and nothing else in the database

Author
Message
koln
koln
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 264
I need to give user Joe select permissions to a view. The view has columns from two tables from the same database (ABC). Joe should only see the columns in this view, not any underlying tables. I should mention that the two tables are owned by Dave.

I thought by writing: "GRANT SELECT ON View1 TO Joe;"

but its not working...I receive the following error;
The SELECT permission was denied on the object 'tblReviews', database 'ABC', schema 'Dave'.

What else can I do ?
Andrew G
Andrew G
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2013 Visits: 2230
Works fine here. You must have a DENY permission set somewhere.


CREATE SCHEMA [Dave]
GO
CREATE USER [Joe] WITHOUT LOGIN
GO
CREATE TABLE [Dave].[Test1] (Col1 INT, Col2 INT, Col3 INT)
GO
INSERT INTO Dave.Test1
VALUES (1,1,1),(2,2,3),(3,2,4)
GO
CREATE VIEW dbo.[Test1]
AS
SELECT Col1, Col2 FROM [Dave].[Test1]
GO

GRANT SELECT ON dbo.[Test1] TO Joe

EXECUTE AS USER = 'Joe'

SELECT * FROM [Dave].[Test1]
--Msg 229, Level 14, State 5, Line 1
--The SELECT permission was denied on the object 'Test1', database 'ABC', schema 'Dave'.

SELECT * FROM dbo.[Test1]
--Col1 Col2
--1 1
--2 2
--3 2


koln
koln
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 264
How can I investigate if I have Deny permissions set somewhere ?
SQLCereal
SQLCereal
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 759
Read through this: http://msdn.microsoft.com/en-us/library/ms176097.aspx. I think example H is what you are looking for.
vikingDBA
vikingDBA
SSC-Enthusiastic
SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)

Group: General Forum Members
Points: 198 Visits: 929
See the following url for an Instance Security Audit script I wrote. It will tell you whether you have a DENY in your permissions for the database. Hope it helps.

http://www.sqlservercentral.com/Forums/Topic1251262-146-1.aspx?Update=1
koln
koln
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 264
Thanks everybody for chiming in...I finally got it to work by this;

Created the view
Went to the view/properties/permissions/ in SMS..find the user that you want to have access...then choose grant for "select" under permissions...thats it.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search