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 |
|
CLages
Posting Yak Master
116 Posts |
Posted - 2004-08-21 : 23:25:31
|
| I have this Triggers, works Fine, but i would like to Put a Extra Column (D = Deleted , U= Updated) in the Log.dbo.areaBut to do this i need to know if the trigger was fired by update or Delete.i would not like to make two Triggers one for UPDATE and other for DELETEtks Carlos LagesCREATE TRIGGER LogArea ON [dbo].[Area] FOR UPDATE ,DELETE ASInsert Log.dbo.area Select Getdate(), System_User , d.* from Deleted as D |
|
|
maydo
Starting Member
20 Posts |
Posted - 2004-08-22 : 03:39:03
|
| After Update the affected records exist in both deleted and inserted tables.After Delete only the deleted table has the afected records.You'll need the PK though.Are You sure you want to reinsert those records in the same Table ?!Insert Log.dbo.area Select Getdate(), System_User , 'U', d.* from Deleted as D inner join inserted as I on I.PK = D.PKUNION ALLSelect Getdate(), System_User , 'D', d.* from Deleted as D left join inserted as I on I.PK = D.PK where I.PK is NULL |
 |
|
|
CLages
Posting Yak Master
116 Posts |
Posted - 2004-08-23 : 09:29:46
|
| Tks.I did not know that After an Update I get both deleted and inserted tables.tks againCarlos Lages |
 |
|
|
|
|
|