Dharan Kumar A
Dharan Kumar A

Reputation: 1

In SSIS, Hoew to assign a value to the variable?

I have SQL Query in that have mentioned like @Result. Now i want to assign the value of @Result to the declared variable in Execute SQL task of DFT. Could you please assist me?

here is the query:

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

Upvotes: 0

Views: 4183

Answers (1)

praveen
praveen

Reputation: 12271

if you want to Output the value of count from the query count(*) from dbo.LDMIntegrityErrorLog then i don't see the importance of the variable @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

Remove the variable @Result in the query

Now create a variable TaskResult of data type int .Map this variable to the result from the above query.

enter image description here

Upvotes: 1

Related Questions