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
转载于:https://www.cnblogs.com/siyunianhua/archive/2011/12/26/2302671.html
转载请注明原文地址: https://mac.8miu.com/read-4992.html