AFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.
Properties
Creation Date
08/01/2010 08:41
Encrypted
Ansi Nulls
Trigger Type
Insert
Delete
Update
After
Instead Of
Trigger Definition
CREATETRIGGER[Sales].[iStore]ON[Sales].[Store]
AFTER INSERTASBEGINDECLARE@Countint;
SET@Count=@@ROWCOUNT;
IF@Count=0RETURN;
SET NOCOUNT ON;
BEGIN TRY
IFEXISTS (SELECT*FROM inserted INNERJOIN[Sales].[Individual]ON inserted.[CustomerID]=[Sales].[Individual].[CustomerID])
BEGINIF@@TRANCOUNT>0BEGINROLLBACKTRANSACTION;
ENDEND;
END TRY
BEGIN CATCH
EXECUTE[dbo].[uspPrintError];
IF@@TRANCOUNT>0BEGINROLLBACKTRANSACTION;
ENDEXECUTE[dbo].[uspLogError];
END CATCH;
END;