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-27 : 11:20:38
|
Hi,I have:tbl_table1Id, Calc1, IsWinning1, 250,02, 350,04, 600,0tbl_table2Id, tbltable1id,Amount,Calculate1, 1,4 , 10, 0I updated in the tbl_table1 column IsWinning:Id, Calc1, IsWinning1, 2.50, 12, 3.50,04, 6.10,1If is IsWinning 1 I need to update column Calculate 2.50*6.10*10:tbl_table2Id, tbltable1id,Amount,Calculate1, 1,4 , 10, 152.50 - this is updated resultI hope you understand what I mean. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-09-28 : 06:09:31
|
[code]CREATE TRIGGER Trig_table1ON tbl_table1FOR UPDATEASBEGINUPDATE tSET t.Calculate = Prdt * AmountFROM tbl_table2 tCROSS APPLY(SELECT EXP(SUM(LOG(Calc1))) AS PrdtFROM tbl_table1 WHERE ',' + t.tbltable1id + ',' LIKE '%,' + CAST(id AS varchar(5)) + ',%')t1END[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|