Grant Select on a view not base table when base table is in a different database

前端 未结 10 1890
广开言路
广开言路 2020-11-30 07:28

I have a view which is selecting rows from a table in a different database. I\'d like to grant select access to the view, but not direct access to the base table. The view

相关标签:
10条回答
  • 2020-11-30 08:21

    I also had this problem. I used information from link, mentioned above, and found quick solution. If you have different schema, lets say test, and create user utest, owner of schema test and among views in schema test you have view vTestView, based on tables from schema dbo, while selecting from it you'll get error mentioned above - no access to base objects. It was enough for me to execute statement

    ALTER AUTHORIZATION ON test.vTestView TO dbo;

    which means that I change an ownership of vTextView from schema it belongs to (test) to database user dbo, owner of schema dbo. After that without any other permissions required user utest will be able to access data from test.vTestView

    0 讨论(0)
  • 2020-11-30 08:22
    GRANT SELECT ON [viewname] TO [user]
    

    should do it.

    0 讨论(0)
  • 2020-11-30 08:29

    I tried this in one of my databases.

    To get it to work, the user had to be added to the database housing the actual data. No rights were needed, just access.

    Have you considered keeping the view in the database it references? Re usability and all if its benefits could follow.

    0 讨论(0)
  • 2020-11-30 08:30

    As you state in one of your comments that the table in question is in a different database, then ownership chaining applies. I suspect there is a break in the chain somewhere - check that link for full details.

    0 讨论(0)
提交回复
热议问题