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

查看:96
本文介绍了如何在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天全站免登陆