2013-04-01 74 views
0

我有SQL查詢中提到像@Result。 現在我想將@Result的值分配給DFT的Execute SQL task中聲明的變量。你能幫我嗎?在SSIS中,Hoew爲變量賦值?

這裏是查詢:

DECLARE @Result SMALLINT 
DECLARE @VALUE SMALLINT 

BEGIN 
SET @VALUE = (SELECT Value 
       from dbo.LDMStockIntegrityCheck 
       where InterfaceName = 'I0180' 
       and FileName = 'PIZ.ED.NBFS001.PICSHT.DATA.LDM') 
SET @Result = 0; 

IF (@VALUE = 1) 
BEGIN 
Select @Result = count(*) from dbo.LDMIntegrityErrorLog 
where InterfaceName = 'I0180' and FileName = 'PIZ.ED.NBFS001.PICSHT.DATA.LDM' 
and CONVERT(VARCHAR(10), DateTime, 120) = CONVERT(VARCHAR(10), getdate(), 120); 
END 

END 
+0

你能告訴你的查詢你的實際做監守在'執行SQL Task'映射可以通過指定'做了什麼?' – praveen

+0

請你幫我 –

回答

0

,如果你想從查詢count(*) from dbo.LDMIntegrityErrorLogOutputcount的價值的話,我看不出變量@Result

DECLARE @VALUE SMALLINT 

BEGIN 
SET @VALUE = (SELECT Value 
       from dbo.LDMStockIntegrityCheck 
       where InterfaceName = 'I0180' 
       and FileName = 'PIZ.ED.NBFS001.PICSHT.DATA.LDM') 

IF (@VALUE = 1) 
BEGIN 
Select count(*) as Result from dbo.LDMIntegrityErrorLog 
where InterfaceName = 'I0180' and FileName = 'PIZ.ED.NBFS001.PICSHT.DATA.LDM' 
and CONVERT(VARCHAR(10), DateTime, 120) = CONVERT(VARCHAR(10), getdate(), 120); 
END 
ELSE 
SELECT NULL AS Result 
END 

取下的重要性變量@Result查詢中

現在創建一個變量TaskResult數據類型爲int。將此變量映射到result從上面的查詢。

enter image description here

+0

感謝您的答覆..但我想知道如何將此變量映射到上述查詢的結果? Iam不確定如何將此變量映射到上述查詢的結果? –

+0

這是我在上面的'image'中顯示的wat。在Execute sql任務的'General'選項卡中,將'Resultset'更改爲'Single Row',並在Result Set中顯示變量 – praveen

+0

In Result Set I給出了像結果名稱= @結果和變量名稱作爲用戶::結果 –