0

我有提到的 SQL Query @Result。现在我想将值赋给 DFT@Result中声明的变量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
4

1 回答 1

1

如果您想从查询Output中获取值,那么我看不到变量的重要性countcount(*) 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上面的查询中。

在此处输入图像描述

于 2013-04-01T10:36:26.037 回答