Hi, i am trying to Update some records in my table but the update statement is taking for ever ...this is my update Statements
UPDATE Statements..ParticipantFundBalancesSETAct1 = ACT_ID1,TotAct1 = TOT_ACT1,Act2 = ACT_ID2, TotAct2 = TOT_ACT2, Act3 = ACT_ID3, TotAct3 = TOT_ACT3,Act4 = ACT_ID4,TotAct4 = TOT_ACT4,Act5 = ACT_ID5,TotAct5 = TOT_ACT5,Act6 = ACT_ID6,TotAct6 = TOT_ACT6, Act7 = ACT_ID7, TotAct7 = TOT_ACT7,Act8 = ACT_ID8,TotAct8 = TOT_ACT8,Act9 = ACT_ID9,TotAct9 = TOT_ACT9,Act10 = ACT_ID10,TotAct10 = TOT_ACT10,Act11 = ACT_ID11,TotAct11 = TOT_ACT11,Act12 = ACT_ID12,TotAct12 = TOT_ACT12,Act13 = ACT_ID13,TotAct13 = TOT_ACT13,Act14 = ACT_ID14,TotAct14 = TOT_ACT14,Act15 = ACT_ID15,TotAct15 = TOT_ACT15,Act16 = ACT_ID16,TotAct16 = TOT_ACT16,Act17 = ACT_ID17,TotAct17 = TOT_ACT17,Act18 = ACT_ID18,TotAct18 = TOT_ACT18,/*Act19 = ACT_ID19,TotAct19 = TOT_ACT19,Act20 = ACT_ID20,TotAct20 = TOT_ACT20, */ OpeningUnits = UNIT_OP,OPricePerUnit = PRICE_OP,ClosingUnits = UNIT_CL,CPricePerUnit = PRICE_CL,AllocationPercent = ALLOC_PER1FROMStatements..ParticipantFundBalances pfbJOIN (Selectcp.PlanId,p.ParticipantId,@.PeriodId Period,CASE WHEN a.FUND_ID = 'LOAN' Then 0 ELSEf.FundId END FundId,a.ACT_ID1,a.TOT_ACT1,a.ACT_ID2,a.TOT_ACT2,a.ACT_ID3,a.TOT_ACT3,a.ACT_ID4,a.TOT_ACT4,a.ACT_ID5,a.TOT_ACT5,a.ACT_ID6,a.TOT_ACT6,a.ACT_ID7,a.TOT_ACT7,a.ACT_ID8,a.TOT_ACT8,a.ACT_ID9,a.TOT_ACT9,a.ACT_ID10,a.TOT_ACT10,a.ACT_ID11,a.TOT_ACT11,a.ACT_ID12,a.TOT_ACT12,a.ACT_ID13,a.TOT_ACT13,a.ACT_ID14,a.TOT_ACT14,a.ACT_ID15,a.TOT_ACT15,a.ACT_ID16,a.TOT_ACT16,a.ACT_ID17,a.TOT_ACT17,a.ACT_ID18,a.TOT_ACT18,/*a.ACT_ID19,a.TOT_ACT19,a.ACT_ID20,a.TOT_ACT20, */a.UNIT_OP,a.PRICE_OP,a.UNIT_CL,a.PRICE_CL,Cast(Rtrim(i.ALLOC_PER1)as decimal)as ALLOC_PER1FROMASDBF a-- Derive the unique PlanId from the Statements ClientPlan tableINNERJOIN Statements..ClientPlan cpON a.PLAN_NUM = cp.ClientPlanIdANDcp.ClientId = @.ClientId-- Derive the unique ParticipantId from the Statements Participant tableINNERJOIN Statements..Participant pON a.PART_ID = p.PartId
--Derive the unique FundID from the Statements Fund Table...
Left OuterJOIN Statements..Fund fONa.FUND_ID = f.CusipORa.FUND_ID = f.TickerORa.FUND_ID = f.ClientFundId-- get the allocation percent from the INVSRCLEFTOuter JOIN INVSRC iONa.FUND_ID = i.INV_IDANDa.PLAN_NUM = i.Plan_NumberANDa.PART_ID = i.PART_IDWHEREa.Import = 1)aON pfb.PlanId = a.PlanIdANDpfb.ParticipantId = a.ParticipantIdANDpfb.PeriodId = PeriodIdAND pfb.FundId = a.FundId
While i insert data in my table i am checking if there are any loans in the ASDBF table and if there i am inserting a 0 in the particular
i am trying to up date the with in 3 different plans in the same table..
any help will be appreciated.
Regards
Karen
Never mind i fixed it by doing a group by..
Regards
Karen
No comments:
Post a Comment