Venil
Venil

Reputation: 415

How do i fire a trigger while truncating a table?

I am using MS SQL server 2008. Right now am firing my trigger on deleting records from my Master table to delete corresponding records from my child table. Now am trying to fire the trigger on truncate on my Master table. Is it possible? If yes, kindly help me to find the solution.

Upvotes: 0

Views: 1365

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300559

TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.

Ref.

Suggest you perform an actual delete, and perform in batches if this was the original reason (i.e. locking) you used TRUNCATE instead of DELETE

Upvotes: 1

Related Questions