Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Folks,

I have a stored procedure which generates a .csv file, now if this CSV file contains any record then only SSIS should trigger a mail, I am a beginner in SSIS so don't know how to implement this.

My stored procedure doesn't have any output and input parameter. The condition at end in my SP is
SQL
IF (select COUNT(*) FROM Table) > 1
begin 
  exec master..xp_cmdshell @SQL 
  return 1;
  end
  else return 0

As of now there are 2 tasks in my control flow in SSIS
1. Execute SQL task for calling Stored procedure
2. Send mail task for sending mail

Now, I want step 2 to get executed only my SP returns 1 or else it should not execute send mail task. Could anyone please help on this?

What I have tried:

I have used below login in my main method of script task but it's not working properly
C#
cmd.CommandType = CommandType.StoredProcedure;

cmd.ExecuteNonQuery();

string returnValue = (string)cmd.ExecuteScalar();
MessageBox.Show(returnValue);
if(returnValue=="1")
Dts.TaskResult = (int)ScriptResults.Success;
else
Dts.TaskResult = (int)ScriptResults.Failure;
Posted
Updated 31-Mar-17 11:05am
v2
Comments
j snooze 31-Mar-17 17:09pm    
you should be able to click on the arrow between your 2 tasks and edit that. Then do something based on success or failure of your first step.
Member 12645291 1-Apr-17 0:24am    
yeah i know that but what to write is something which i dont know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900