USE [AdventureWorks]
GO

CREATE TRIGGER [HumanResources].[dEmployee] ON [HumanResouces].[Employee] 
INSTEAD OF DELETE NOT FOR REPLICATION AS 
BEGIN 
SET NOCOUNT ON;


DECLARE @DeleteCount int;


SELECT @DeleteCount = COUNT(*) FROM deleted;
IF @DeleteCount > 0 
BEGIN
RAISERROR
(N'Employees cannot be deleted .They can only be marked as not current .',--message
10,--severity.
1);--State.

--回滚事物
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
END;
END;

GO

 

相关文章:

  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-09-26
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-14
  • 2021-04-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案