简体   繁体   中英

SQL Server: halt an INSERT in a trigger

I have a trigger FOR INSERT and I need to stop the insertion by raising a error.

RAISERROR

will show the error message but is there is a way to halt the action any other method without transactions ?

You have the trigger in the wrong place.

You need an INSTEAD OF trigger instead (no pun intended) to control it. A FOR INSERT trigger occurs AFTER the insert, so the horse has long bolted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM