我正在使用回滚搜索更新后触发器的正确语法:
ALTER TRIGGER UpdatePlayer ON Players
AFTER UPDATE
AS
BEGIN
BEGIN TRY
IF EXISTS(select * from PlayerContract where id in (select id from deleted))
BEGIN
RAISERROR ('No update',16,1)
ROLLBACK
END
ELSE
BEGIN
PRINT 'UPDATE'
END
END TRY
BEGIN CATCH
ROLLBACK
DECLARE @ErrorMessage VARCHAR(500)
SELECT @ErrorMessage = ERROR_MESSAGE()
RAISERROR (@ErrorMessage, 16, 1)
END CATCH
END
当我尝试插入时,我收到以下错误: 消息3609,级别16,状态1,第1行 交易在触发器中结束。批次已中止。