SQL Clone
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
Old Hand
Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)

Group: General Forum Members
Points: 338 Visits: 269
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
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3943 Visits: 2279
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
Old Hand
Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)

Group: General Forum Members
Points: 338 Visits: 269
How can I investigate if I have Deny permissions set somewhere ?
SQLCereal
SQLCereal
SSC-Enthusiastic
SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)SSC-Enthusiastic (108 reputation)

Group: General Forum Members
Points: 108 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
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1162 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
Old Hand
Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)Old Hand (338 reputation)

Group: General Forum Members
Points: 338 Visits: 269
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