CREATE SECURITY POLICY
defines a security policy: FILTER predicates silently filter reads; BLOCK predicates reject writes
What changes
- Input
- predicate function (inline TVF) and target tables
- Output or change
- row-level security policy
Syntax at a glance
CREATE SECURITY POLICY [schema_name. ] security_policy_name { ADD [ FILTER | BLOCK ] } PREDICATE tvf_schema_name.security_predicate_function_name ( { column_name | expression } [ , ...n] ) ON table_schema_name. table_name [ <block_dml_operation> ] , [ , ...n] [ WITH ( STATE = { ON | OFF } [,] [ SCHEMABINDING = { ON | OFF } ] ) ] [ NOT FOR REPLICATION ] [;]
Work example
Rows need a filter or block predicate tied to the caller's database identity.
Test each predicate as two synthetic principals and review bypass permissions and schema binding.
Check your work Each test principal sees only its allowed rows and cannot write across the policy boundary.
Open Microsoft Learn for full syntax, permissions, and details for your version.