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)
 problem with trigger

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2014-10-08 : 04:35:48
my tables:

tbl_details
Id, Check,
10, 1
76, 2


tbl_system:
Id, System, Amount
1 10,76

With trigger I want if have Check=2 from tbl_details then and if exists in tbl_system.System=76 insert in Amount 0.00

How to do it?




programer
Posting Yak Master

221 Posts

Posted - 2014-10-08 : 06:27:51
really you do not know my question?
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2014-10-08 : 07:32:34
quote:
Originally posted by programer

my tables:

tbl_details
Id, Check,
10, 1
76, 2


tbl_system:
Id, System, Amount
1 10,76

With trigger I want if have Check=2 from tbl_details then and if exists in tbl_system.System=76 insert in Amount 0.00

How to do it?








Check my code... working but problem is because i have in my column SystemBet=1029, 2032 and I need to set=0 when is result updatewin= (SELECT TOP 1 BetSlipEventID FROM @Odds where IsWinning=2) in my case is 2032, but now not working because is also 1029... So I need to also use update if my code contains 1029,or etc...

if find 2032 then use update...

DECLARE @Odds AS Table
(
SrNo INT IDENTITY,
BetSlipEventID INT,
IsWinning INT,
Odds FLOAT,
SlipSystemId INT,
StaKe FLOAT,
BetSlipDetailID INT
)

INSERT INTO @Odds(BetSlipEventID,IsWinning,Odds,SlipSystemId,StaKe,BetSlipDetailID)
SELECT CAST(string AS INT) BetSlipEventID,BSE.IsWinning,BSE.Odds,BSS.Id,BSS.Stake,BSS.BetSlipDetailId
FROM tbl_BetSlipSystem BSS
OUTER APPLY dbo.fnParseStringTSQL(BSS.SystemBet, ',') AS T
INNER JOIN tbl_BetSlipEvents BSE ON BSE.BetSlipDetailId=BSS.BetSlipDetailId
AND BSE.ID=CAST(T.string AS INT)
INNER JOIN tbl_BetSlipEvents I ON BSE.BetSlipDetailId=I.BetSlipDetailId
ORDER BY BSS.Id ASC,IsWinning DESC


declare @updatewin nvarchar(4000)
set @updatewin = (SELECT TOP 1 BetSlipEventID FROM @Odds where IsWinning=2)

--(SELECT TOP 1 BetSlipEventID FROM @Odds where IsWinning=2)

update tbl_BetSlipSystem
set Win =0
where SystemBet= @updatewin
Go to Top of Page
   

- Advertisement -