Friday, November 19, 2010

How to trigger event for Truncate action in MS SQL


I guess it is not possible to trigger event for Truncate,but prevent it.

From msdn:
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. We can prevent truncate action,if we create a view WITH SCHEMABINDING.

If we don't use truncate on the application level, we will be dealing with only delete command. It is easy to prevent that with Instead Of Trigger.

No comments:

Post a Comment

Let me know what you think?