Pregunta

If I have the following view:

CREATE VIEW [dbo].[vw_Sample]
AS
    SELECT  T1.Column1, 
            T1.Column2,
            Table2.Column1, 
            Table2.Column2
    FROM dbo.Table1 T1
    JOIN dbo.Table2 T2 ON T2.Column3 = T1.Column3
GO

And I want to grant a user access to SELECT from that view; do I need to either:

A - Give that user SELECT permissions on just the view:

GRANT SELECT ON [dbo].[vw_Sample] TO [MyUser]

or

B - Give that user SELECT permissions on view and underlying tables:

GRANT SELECT ON [dbo].[Table1] TO [MyUser]
GRANT SELECT ON [dbo].[Table2] TO [MyUser]
GRANT SELECT ON [dbo].[vw_Sample] TO [MyUser]
¿Fue útil?

Solución

Just the View (A). Granting Select on the underlying tables will give them more access than they may need. The link below has some helpful info on ownership of the view\table and the affects it may have on your access.

Grant SELECT permission on a view, but not on underlying objects

Otros consejos

B. Each object you created (view, procedure or function) will be execute under caller permissions. So, trying to select from underlying tables without necessary permissions will cause permission error. Or you may use EXECUTE AS/SET USER statements: please refer to TechNet article: http://technet.microsoft.com/en-au/library/ms188268(v=sql.105).aspx

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top