I have 5 parameters defined:
1. TopCount
2. StartDate
3. EndDate
4. RegionCode
5. Order
I have the following code as query type = text:
set nocount on
-----------------------------------------------------------------------------------
--Create temp tables
CREATE TABLE #Securities(SecurityID int, SecurityName varchar(100), Identifier varchar(12), PrimaryExchangeID int,
StartPrice money, EndPrice money, PriceVariance float,
SharesOutStartDate bigint, SharesOutEndDate bigint,
SharesOutVariance numeric(18,4), StartDateIntrinsicRate numeric(18,4), EndDateIntrinsicRate numeric(18,4),
ChangeInIntrinsicRate numeric(18,4))
-----------------------------------------------------------------------------------
INSERT INTO #Securities(SecurityID, SecurityName, Identifier, PrimaryExchangeID, StartPrice)
Select s.SecurityID, s.SecurityName, s.PrimaryISIN, s.PrimaryExchangeID, t.Price
From SecMast.dbo.Securities s with (nolock)
inner join SecMast.dbo.TradingData t with (nolock)
on s.SecurityID = t.SecurityID
inner join SecMast.dbo.AssetClasses a with (nolock)
on s.AssetClassID = a.AssetClassID
inner join SecMast.dbo.Countries c with (nolock)
on s.ISOCountryCode = c.ISOCountryCode
Where t.[Date] = @StartDate
and a.AssetClassGroupID = 'EQU'
and t.Price is not null
and t.ExchangeID = s.PrimaryExchangeID
and c.RegionCode = @RegionCode
-----------------------------------------------------------------------------------
--Update temp table
Update s
Set EndPrice = t.Price
From #Securities s
inner join SecMast.dbo.TradingData t with (nolock)
on s.SecurityID = t.SecurityID
Where t.[Date] = @EndDate
and t.Price is not null
and t.ExchangeID = s.PrimaryExchangeID
Delete from #Securities Where EndPrice is null
="Update s Set SharesOutStartDate = (isnull(d.Units,0)), StartDateIntrinsicRate = d.LoanRateAvg From #Securities s inner join Summary.dbo.daisyx_persecurity d with (nolock) on s.SecurityID = d.SecurityID Where d.[Date] = 'CAST(" & Parameters!StartDate.Value& " as varchar(30))' and d.ContractTypeID = 11 and d.LoanStageID = 1 and d.CollateralTypeID = 'A' and d.CollateralCurrencyID = 'AAA'"
--I get an error on the last update statement. I am not sure what is wrong here. Any ideas?