im using variable tables have the first part working the way i wantafter the first part i need to use another table and the info from my temptable to get the data i needhere is my codeDECLARE @FirstTable TABLE( Fk_fund int, Date datetime, isin nvarchar(12), Fundname ntext, ShareCurrency nvarchar(3), Pricepershare numeric, exchanegRate numeric, FirstSimulation nvarchar(20), SecondSimulation nvarchar(20), ThirdSimulation nvarchar (20)) INSERT INTO @FirstTable (Fk_fund, Date,isin,Fundname,ShareCurrency, Pricepershare, exchanegRate,FirstSimulation,SecondSimulation,ThirdSimulation)SELECT dp.Fk_fund , dp.Date , dp.isin , dp.Fundname, dp.ShareCurrency , dp. Pricepershare , dp. exchanegRate , s.FirstSimulation , s.SecondSimulation , s.ThirdSimulation FROM generic.DailyPrice dpinner join generic.Simulation s on dp.ISIN =s.ISINwhere Date= (SELECT MAX(Date) FROM generic.DailyPrice) select * from generic.HistoricalPrice hpinnerjoin @FirstTable on hp.ISIN = @FirstTable.ThirdSimulationwhere hp.Date > @FirstTable.date
its the last part im having trouble with select * from generic.HistoricalPrice hpinnerjoin @FirstTable on hp.ISIN = @FirstTable.ThirdSimulationwhere hp.Date > @FirstTable.date
getting this errorMsg 137, Level 16, State 1, Line 39Must declare the scalar variable "@FirstTable".any ideas