我有SQL查询,提到过@Result
。
现在我想将@Result
的值赋给DFT的Execute SQL task
中的声明变量。你能帮帮我吗?
这是查询:
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 :(得分:1)
如果您想Output
来自查询count
count(*) from dbo.LDMIntegrityErrorLog
的值,那么我看不到变量@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
。