question

Kiran avatar image
Kiran asked

How to avoid a DDL trigger being deleted?

hi, i have created a DDL trigger with encryption for to restrict users from modify any table / proc / functions in my database. but from SQL Server Management studio user can directly drop my ddl trigger itself.

How to avoid this? pls give solution.

with regards Kiran K

triggerddl
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered

You can't avoid it always. If a user has permissions to delete your DDL trigger, then they can delete it. You could create another DDL trigger to stop the first one from being deleted, but they could then just delete that one.

That having been said, you could DENY ALTER ANY DATABASE DDL TRIGGER permission to the database users, which would prevent the DDL trigger from being dropped.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image
Fatherjack answered

Someone will only be able to drop the trigger if they have the required permission in that database. Setting the security so that they are not allowed to drop objects will prevent your trigger being removed.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image Matt Whitfield ♦♦ commented ·
+1 - quicker than me :)
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.