如何取消 SQL 中的删除 [英] How do I cancel a Delete in SQL

查看:21
本文介绍了如何取消 SQL 中的删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个触发器来根据业务规则检查正在删除的内容,然后在需要时取消删除.有什么想法吗?

I want to create a trigger to check what is being deleted against business rules and then cancel the deletion if needed. Any ideas?

该解决方案使用了替代删除触发器.Rollback tran 停止了删除.我担心在删除时会出现级联问题,但这似乎没有发生.也许触发器不能触发自身.

The solution used the Instead of Delete trigger. The Rollback tran stopped the delete. I was afraid that I would have a cascade issue when I did the delete but that didn't seem to happen. Maybe a trigger cannot trigger itself.

推荐答案

使用 INSTEAD OF DELETE(请参阅 MSDN) 触发器并在触发器内决定您真正想要做什么.

Use an INSTEAD OF DELETE (see MSDN) trigger and decide within the trigger what you really want to do.

这篇关于如何取消 SQL 中的删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆