im using variable tables have the first part working the way i want
after the first part i need to use another table and the info from my temptable to get the data i need
here is my code
DECLARE @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 dp
inner
join generic.Simulation s
on dp.ISIN =s.ISIN
where Date=
(SELECT MAX(Date) FROM generic.DailyPrice)
select * from generic.HistoricalPrice hp
inner
join @FirstTable
on hp.ISIN = @FirstTable.ThirdSimulation
where hp.Date > @FirstTable.date
its the last part im having trouble with
select * from generic.HistoricalPrice hp
inner
join @FirstTable
on hp.ISIN = @FirstTable.ThirdSimulation
where hp.Date > @FirstTable.date
getting this error
Msg 137, Level 16, State 1, Line 39
Must declare the scalar variable "@FirstTable".
any ideas