SQL Server 2016 更改 Table 重要功能 -- 更改安全策略

SQL Sever 2016 Alter Table Valued Function -- Alter Security Policy

我有一个被安全策略引用的 table 值函数。 我想 ALTER 这个功能,但我不能:

Msg 3729, Level 16, State 3, Procedure accessPredicate, Line 1
Cannot ALTER 'rls.accessPredicate' because it is being referenced by object 'EventSecurityPolicy'

嗯,但是 GUI 中的安全策略在哪里?我已经检查了模式、table 和函数。我假设它会受到政策的约束

好的,我总是可以用 T-SQL

select * 
from sys.security_policies

也许我可以关掉它

Alter security policy rls.EventSecurityPolicy
with (state = OFF);

没有同样的错误:

Msg 3729, Level 16, State 3, Procedure accessPredicate, Line 1
Cannot ALTER 'rls.accessPredicate' because it is being referenced by object 'EventSecurityPolicy'

好的,我们删除它

delete from sys.objects
where schema_id = schema_id('rls') and object_id='1253579504'

Msg 259, Level 16, State 1, Line 2
Ad hoc updates to system catalogs are not allowed.

How do you get past this sort of error: "Ad hoc updates to system catalogs are not allowed."?

好的,我会更改程序集..

select * from sys.assemblies

好吧,我不知道从这里去哪里....

一定有更简单的方法!我只是想改变一个功能!

解决方案--

删除谓词:

ALTER SECURITY POLICY rls.EventSecurityPolicy DROP filter PREDICATE ON 
dbo.Dim_event
ALTER SECURITY POLICY rls.EventSecurityPolicy DROP BLOCK PREDICATE ON 
dbo.Dim_event AFTER UPDATE

然后修改函数: