I have the following rather simple statement in SQL Server Mgmt Studio 2016 CTP 3.2:
if exists(select null from sys.security_policies where name = 'OrganisationSecurityPolicy') begin alter security policy [security].OrganisationSecurityPolicy with (state = off) end
A security policy with that name does indeed not exist so nothing should happen. However, I get an error:
Msg 33268, Level 16, State 2, Line 3 Cannot find the object "security.OrganisationSecurityPolicy" because it does not exist or you do not have permissions.
Is there something special about security policies that makes this impossible? If I replace the
alter security policy with an
alter table for a non-existing table, the statement simply isn't executed.