How can I achieve row level security in SQL Server 2014

前提是你 提交于 2019-12-13 03:04:30

问题


Is there any way to get row-level security in SQL Server 2014?

My problem is:

  • I have a table with data for multiple regions
  • I created a view for each region
  • Specific user will have access to specific region views
  • But without giving access to the underlying table, those users are unable to access the views

I need to restrict users to view only certain rows. Are there any possibilities to do so?


回答1:


I have achieved it by creating views for the specified rows and giving permission to only views not underlying table

  • so user has visible to only rows which are returned by views. We can control rows to be returned by where clause in view.
  • but table may contain other rows as well

key terms : Ownership chaining




回答2:


The same SQL query returns results based on identity. No special database code required. You can control how the rows and columns return, and even aggregation. For example, the SQL below will return different results for managers, analysts, and developers. select * from employee_salaries;



来源:https://stackoverflow.com/questions/56374061/how-can-i-achieve-row-level-security-in-sql-server-2014

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!