How can I achieve row level security in SQL Server

2019-08-23 00:49发布

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?

2条回答
在下西门庆
2楼-- · 2019-08-23 01:39

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;

查看更多
【Aperson】
3楼-- · 2019-08-23 01:51

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

查看更多
登录 后发表回答