Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Triggers Revisted - Better Way?

Author  Topic 

DavidChel
Constraint Violating Yak Guru

474 Posts

Posted - 2008-08-25 : 14:49:08
This is how my code determines which type of action was taken on the table. This determines that it is a delete.

    IF NOT EXISTS ( SELECT  *
FROM inserted )
AND EXISTS ( SELECT *
FROM deleted ) -- Delete


This works, but I know there has to be a better way to do it. Can someone recommend one?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-08-25 : 14:58:46
Create one trigger for delete and another trigger for insert.




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -