0
我想將一個參數值傳遞給一個具有四個參數和「返回表」的表值函數。然而,當我的參數值傳遞給它的VARCHAR參數之一,收到以下錯誤:將參數傳遞給一個表值函數
消息8114,級別16,狀態5,第6行誤差變換數據類型爲varchar 爲bigint。
declare @Scenario1 as varchar(30)
set @Scenario1 = '2017_B01'
select *
From [dbo].[fn_GetAEAssumptionFacts](@Scenario1,null,null,null) fng
一瞥功能:
CREATE FUNCTION [dbo].[fn_GetAEAssumptionFacts]
(
@pScenarioName varchar(500) = NULL
,@pBuildingID varchar(500) = NULL
,@pLeaseID varchar(500) = NULL
,@pTenantName varchar(500) = NULL
)
RETURNS TABLE
AS
RETURN
select
.....
from ae11.dbo.rvw_FinancialLineItems fli
....
INNER JOIN ae11.dbo.rvw_Scenarios s on s.Id = pas.ScenarioId
left join
(select
externalID,
PropertyAssetId,
LeaseID,
BeginDate
from ae11.dbo.ivw_Leases
WHERE PropertyAssetID IN
(select ID from AE11.dbo.PropertyAssets where scenarioID =
(CASE WHEN isnull(@pScenarioName, '') = ''
THEN (select ID from AEX.[dbo].[ConfigurationFieldTable]
where [Type] = 'Lease Connect Current Scenario')
ELSE @pScenarioName
END)
)
) lea
ON lea.LeaseID = uni.ExternalID
AND lea.PropertyAssetID = uni.PropertyAssetId
where 1=1
......
AND s.id = (CASE WHEN isnull(@pScenarioName, '') = ''
THEN (select ID from AEX.[dbo].[ConfigurationFieldTable]
where [Type] = 'Lease Connect Current Scenario')
ELSE @pScenarioName
END)
謝謝你讓我意識到我的錯誤。 scenarioID是一個整數值,我的參數正在嘗試傳遞一個varchar值。 – NonProgrammer