我在 SQL Server 2008 中创建了一个触发器
CREATE TRIGGER [dbo].[ITEM_UOM_DELETE] ON
[dbo].[ITEM_UOM] INSTEAD OF DELETE
AS
declare @rowc int
set @rowc = (select count(*) from stock, deleted where
item = deleted.itemcode and uom = DELETED.MAINUNIT AND DOCTYPE <> 'OP')
if @rowc > 0
begin
raiserror('Unit is in Use Cannot Delete', 16, 1)
rollback transaction
end
在执行此触发器时,它会给出错误输出
Msg 50000, Level 16, State 1, Procedure ITEM_UOM_DELETE, Line 11
Unit is in Use Cannot Delete
Msg 3609, Level 16, State 1, Line 1
事务在触发器中结束。该批次已中止。
我只想要定义的错误
单位正在使用中无法删除
如何删除错误“事务在触发器中结束。批次已中止。?