Hide Base Tables: Select + Update using Views [Access/SQL2000]

  • For Users[+ db Roles]:

    Can I disallow Select on a table, yet give the users Select + Update on a View based on the table?

    Is the task much simpler if we switch from SQL2000 to SQL2005?

    ANY help is always appreciated.

    jb

  • It is possibile. It isn't simpler with SQL2005, mainly because it couldn't be any simpler.

    Here's an example with SQL2005:

    USE testDB

    CREATE TABLE testtable (

    test INT

    )

    INSERT INTO testtable VALUES(1)

    INSERT INTO testtable VALUES(2)

    INSERT INTO testtable VALUES(3)

    GO

    CREATE VIEW testview

    AS

    SELECT * FROM testtable

    DENY UPDATE ON testtable TO testuser

    EXECUTE('UPDATE testtable SET test = test + 1') AS USER = 'testuser'

    --Msg 229, Level 14, State 5, Line 1

    --The UPDATE permission was denied on the object 'testtable', database 'TestDB', schema 'dbo'.

    EXECUTE('UPDATE testview SET test = test + 1') AS USER = 'testuser'

    --(3 row(s) affected)

    DROP VIEW testview

    DROP TABLE testtable

    Regards

    Gianluca

    -- Gianluca Sartori

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply