PSK
PSK

Reputation: 17953

Enable disable a security policy in SQL Server

I have created a Security Policy to implement Row Level Security (RLS) in SQL Server 2016. There is some specific time in a month when the security policy will be applicable. I am planning to write a job which will enable or disable the Security Policy, but I am not getting the SQL command to disable or enable it.

I know that I need to set the check_policy to OFF

CHECK_POLICY = { OFF } 

Visually I am able to do it using Sql Server Management Studio by right clicking on the Security Policy.

Upvotes: 1

Views: 7455

Answers (2)

S.Kain
S.Kain

Reputation: 11

Using TheGameiswar's answer works I wanted to add that if you get an error saying

Cannot find the object "[security filter name]" because it does not exist or you do not have permissions.

Append [security] before the filter name

For example if your filter name is "ProfilesFilter"

ALTER SECURITY POLICY [security][ProfilesFilter] WITH (STATE=OFF)

This is probably a given for some but I am less fluent with SQL/SQL Server

Upvotes: 1

TheGameiswar
TheGameiswar

Reputation: 28940

Won't this work..

ALTER SECURITY POLICY <<your security policy>>
WITH (STATE = OFF); 

Upvotes: 6

Related Questions