Reputation: 157
I wanted to know the SQL Syntax to Deny Disabling a Trigger for a User Group. There is a crucial trigger that is being disabled and re-enabled by some folks. I want to prevent that from being disabled in the first place. So I tried the following syntax.
USE [MyDBName]
GO
DENY ALTER ON OBJECT::[dbo].[TRIG_SomeName_DELETE] TO [UserGroup];
But i get an error like 'Cannot find the object 'TRIG_SomeName_DELETE', because it does not exist or you do not have permission.'. I have tried executing the above statements from a sql account that has elevated privileges. But I keep getting the same Error. I'm thinking that I might not be using the correct syntax for Denying Disable Trigger Permissions. I'd greatly appreciate any help on this.
Upvotes: 1
Views: 811
Reputation: 280615
You need to leave out [dbo].
since a database-level trigger does not belong to a schema. Also, database-level triggers do not have an ALTER
permission. You'll have to prevent them from editing any database-level trigger (using the aptly-named ALTER ANY DATABASE DDL TRIGGER
permission):
USE [MyDBName];
GO
DENY ALTER ANY DATABASE DDL TRIGGER TO [UserGroup];
This will prevent anyone in UserGroup
from creating, dropping, changing, enabling, or disabling any database-level DDL triggers.
Upvotes: 1