SSIS - Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

Naomi Nosonovsky 8,351 Reputation points
2025-04-29T18:42:22.52+00:00

Hi,

I am getting this error Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done which I cannot figure out. My execute SQL Task has the following code which I can run in SSMS fine:

DECLARE @errorMsg VARCHAR(max) ;

DECLARE @cntAdr INT = ?;
DECLARE @cntFooterAdr INT = 0;

DECLARE @cntAdrLang INT = ?;
DECLARE @cntFooterAdrLang INT = 0;

DECLARE @cntPatc INT = ?;
DECLARE @cntFooterPatc INT = 0;


SELECT @cntFooterAdr = cntRows
FROM ref.ref_ndb_FileRows n
WHERE n.[fileName] LIKE 'Adr[_]%'
      AND CAST(LoadDate AS DATE) = CAST(CURRENT_TIMESTAMP AS DATE);

IF @cntAdr != @cntFooterAdr
BEGIN
    SET @errorMsg = CONCAT('Address Row Count ', @cntAdr, ' does not match footer row count ', @cntFooterAdr, '.');
    

END;

SELECT @cntFooterAdrLang = cntRows
FROM ref.ref_ndb_FileRows n
WHERE n.[fileName] LIKE 'AdrLang[_]%'
      AND CAST(LoadDate AS DATE) = CAST(CURRENT_TIMESTAMP AS DATE);

IF @cntAdrLang != @cntFooterAdrLang
BEGIN
    SET @errorMsg = ISNULL(@errorMsg + CHAR(13),'') + CONCAT('AdrLang Row Count ', @cntAdrLang, ' does not match footer row count ', @cntFooterAdrLang, '.');
   

END;

SELECT @cntFooterPatc = cntRows
FROM ref.ref_ndb_FileRows n
WHERE n.[fileName] LIKE 'Patc[_]%'
      AND CAST(LoadDate AS DATE) = CAST(CURRENT_TIMESTAMP AS DATE);

IF @cntPatc != @cntFooterPatc
BEGIN
    SET @errorMsg = ISNULL(@errorMsg + CHAR(13),'') + CONCAT('Contacts Row Count ', @cntPatc, ' does not match footer row count ', @cntFooterPatc, '.');
   

END;

SELECT @errorMsg as errorMsg;

The parameters are configured as follows:

enter image description here

I cannot figure out where the error is.

Thanks in advance

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,681 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Naomi Nosonovsky 8,351 Reputation points
    2025-04-29T20:45:40.1166667+00:00

    Figured this out. Apparently we need to have DECLARE statement for each parameter.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.