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 |
programer
Posting Yak Master
221 Posts |
Posted - 2013-09-18 : 08:52:33
|
Hello,i need multiple insert with different where.My trigger:ALTER TRIGGER [dbo].[BetSlipEventsTrigger]ON [dbo].[tbl_BetSlipEvents]AFTER INSERT, UPDATE, DELETEASSET NOCOUNT ON;WITH cteSource(ID, rn)AS ( SELECT ID, ROW_NUMBER() OVER (ORDER BY ID) AS rn FROM inserted)MERGE dbo.tbl_BetSlipSystem AS tgtUSING ( SELECT ID FROM cteSource WHERE rn IN (1, 3) ) AS src ON src.ID = tgt.BetSlipEventIDWHEN NOT MATCHED BY TARGET THEN INSERT ( BetSlipEventID ) VALUES ( src.ID )WHEN NOT MATCHED BY SOURCE THEN DELETE;This is works but I want to insert where is 1,3 SELECT ID FROM cteSource WHERE rn IN (1, 3)HEN NOT MATCHED BY TARGET THEN INSERT ( BetSlipEventID ) VALUES ( src.IDIt's ok.And then I want to insert where is 2,3SELECT ID FROM cteSource WHERE rn IN (2, 3)HEN NOT MATCHED BY TARGET THEN INSERT ( BetSlipEventID ) VALUES ( src.IDpls help |
|
|
|
|