我想将 SELECT TOP 1...... 的结果分配给我的 SQL Server 存储过程中的局部变量。请在下面找到存储过程的部分:
SELECT
(
SELECT @billingMeterID = TOP 1 bmt.BillingMeterTypeID
FROM SDP_BillingMeterType bmt
JOIN SDP_Series s ON s.SeriesID = bmt.SeriesID
WHERE s.EngineID = SDP_PricePointBase.EngineID
) AS BillingMeterTypeID,
dbo.fn_GetTotalStreetCost(EngineID, ProgramID, ConsumableTypeID, @billingMeterID) AS StreetCost,
[PricePointBaseID] AS PricePointBaseID,
(SELECT TOP 1 CountryID FROM SDP_Country) AS CountryID,-- Only US is considered for now
dbo.fn_GetTotalStreetCost(EngineID, ProgramID, ConsumableTypeID, @billingMeterID) * 0.5 AS StatedCost
@dummyCost AS StreetCostUSD,
@dummyCost AS StreetCostEURO,
@dummyCost AS StatedCostUSD,
@dummyCost AS StatedCostEURO,
@exchangeRateSourceID AS ExchangeRateSourceID -- populating dummy value as the source is unknown at present
FROM SDP_PricePointBase