Microsoft SQL Server Row-level security Altering RLS security policy

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Security policy is a group of predicates associated to tables that can be managed together. You can add, or remove predicates or turn on/off entire policy.

You can add more predicates on tables in the existing security policy.

ALTER SECURITY POLICY dbo.CompanyAccessPolicy
    ADD FILTER PREDICATE dbo.pUserCanAccessCompany(CompanyID) ON dbo.Company

You can drop some predicates from security policy:

ALTER SECURITY POLICY dbo.CompanyAccessPolicy
    DROP FILTER PREDICATE ON dbo.Company

You can disable security policy

ALTER SECURITY POLICY dbo.CompanyAccessPolicy WITH ( STATE = OFF );  

You can enable security policy that was disabled:

ALTER SECURITY POLICY dbo.CompanyAccessPolicy WITH ( STATE = ON );  


Got any Microsoft SQL Server Question?