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.
| Author |
Topic |
|
sneh sharma
Starting Member
4 Posts |
Posted - 2008-06-19 : 05:51:55
|
| Hi,I have a query regarding DML Triggers.I have created a trigger ON a table AFTER Insert, Update staement. In the trigger's body I am making a call to a stored procedure. In the procedure, I want to know the Trigger invoked due to which event : insert or Update as I have to handle bith the cases differently.But I am not able to find out any SQL server function or property which can distinguish between INSERT and Update events of a trigger. Waiting for the needful. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-19 : 05:57:12
|
| you can distinguish Insert update actions with the help of internal tables INSERTED & DELETEDIF EXISTS(SELECT 1 FROM INSERTED) AND EXISTS(SELECT 1 FROM DELETED) for updateand IF EXISTS(SELECT 1 FROM INSERTED) AND NOT EXISTS(SELECT 1 FROM DELETED)for insert |
 |
|
|
sneh sharma
Starting Member
4 Posts |
Posted - 2008-06-19 : 06:24:07
|
| No, I want to know that the last event that occured on table was an insert or update, not that any insert or update ever occured on table. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-19 : 06:40:53
|
1) Read the log2) Provide some auditing E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sneh sharma
Starting Member
4 Posts |
Posted - 2008-06-19 : 06:52:02
|
| It worked....thanks visakh |
 |
|
|
|
|
|