开发者

SQL trigger on Truncate

开发者 https://www.devze.com 2022-12-20 04:20 出处:网络
How to Fire a trigger when you do TRUNCATE (instead deleted) in MSS开发者_如何转开发QLFrom msdn:

How to Fire a trigger when you do TRUNCATE (instead deleted) in MSS开发者_如何转开发QL


From msdn:

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


You can't do this on SQL server.

From MSDN

TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. For more information, see CREATE TRIGGER (Transact-SQL).


Are you letting users run TRUNCATE TABLE ad hoc / willy nilly? If not, instead of worrying about using a trigger, why not wrap the TRUNCATE command in a stored procedure that also deals with whatever the trigger would have done after the truncate finished? (But you'd have to do it in the opposite order, of course.)

0

精彩评论

暂无评论...
验证码 换一张
取 消