I have insert records from excel sheet to SQL using
Code runs fine for me.
But I have to fire Trigger based insertion.
In trigger I am inserting records in another table based on
that also works fine.
but if I am checking that another table already having that record which I am trying to insert and update that record than that does not works for me.
How can I solve my problem ?
Use Merge statement in your Trigger if you are using SQL server 2008
MERGE INTO dbo.Table1 AS t USING dbo.inserted AS i ON t.id= i.id WHEN MATCHED THEN UPDATE SET t.col1= i.col1, t.col2= i.col2 WHEN NOT MATCHED THEN INSERT (col1, col2) VALUES (i.col1, i.col2)