Link to home
Start Free TrialLog in
Avatar of paultran00
paultran00Flag for United States of America

asked on

SSIS 2008 - How to check for no data returned from stored procedure

Hi guys,

I have an ssis package that has a 'EXECUTE SQL TASK' that calls a stored procedure A that returns data.  

THIS WORKS When there's data from Stored Procedure A then the downstream task Foreach Loop Container runs a Script Task which sends out an email with the subject='JOB SUCCESSFUL!' and a dynamic content with data from the STORED PROCEDURE A.

PROBLEM:  

THIS DOES NOT WORK:  When there's NO data in stored procedure A then I don't want to run the downstream  task Foreach Loop Container. How do I do that (I'm using Visual Basic 2008 in the SCRIPT TASK)?

Please show me a step by step settings/configuration/code.

NOTE: I'm using SQL SERVER 2008R2.

Thank you.
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

at the end of the stored procedure you can check

@@ROWCOUNT

IF @@ROWCOUNT > 0

You can pass value from a stored procedure to the caller using OUTPUT parameter.
Avatar of paultran00

ASKER

HI. Would you please send me an example of a stored procedure that's called from ssis that runs a SELECT then also uses the rowcount as OUTPUT parameter?
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much.