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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 trigger

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2013-09-26 : 15:01:25
tbl_Events:
Id, DetailId,Date,Event
1838 598 NULL 28.9.2013 11:45:00 Tottenham - Chelsea 3Way - result Tottenham NULL 2,65 0
1839 598 NULL 28.9.2013 14:00:00 Aston Villa - Manchester City 3Way - result Aston Villa NULL 7,00 0
1840 598 NULL 28.9.2013 14:00:00 Fulham - Cardiff City 3Way - result Fulham NULL 2,10 0

tbl_System
Id, BetSlipDetailId, BetSlipEventId,SystemId
2990 598 1838 1838,1839|1838,1840

My code:
--AB
Insert into tbl_BetSlipSystem(BetSlipDetailId,BetSlipEventId,SystemBet)
Select BetSlipDetailId,Id,'AB' from
(Select row_number() over(order by id) as Number, Id,BetSlipDetailId from inserted) as a
Where a.Number IN (1,2|1,3)


So, If I first select row_number 1,2 and then 1,3.

In the table tbl_System I need to insert Id from first table:
1838,1839|1838,1840
   

- Advertisement -