how to create triggers with delete and update
i have a table called dbo.OrderDetail with columns (OrderId,OrderDate,OrederArea,OrderCode,CreateDate] and created audit table with new column called flag that opearted Del and Upd to handle update and delete operations;
My SSIS package pulls data from file to stage table. after this process it will procedure that inserts records into dbo.Order from temp.Order stg where not exits (select 1 from dbo.Order Od
where stg.OrderId = Od.OrderId
and stg.OrderDate = Od.OrderDate
and stg.OrederArea = Od.OrderArea
and stg.OrderCode = Od.OrderCode)
Probelm is that form the source we may get duplicates. if there is already data existing with one order id and order date , if the new data comes over it should update exisitng record.
if all 4 columns data exists already and the new data matched with exisitng it shoudl delete using trigger.