title: How to control SSIS package flow based on record count returned by a query?
body: <p>I'm trying to first check if there are any new records to process before I execute my package.  I have a bit field called "processed" in a SQL Server 2008 R2 table that has a value of 1 if processed and 0 if not.  </p>
  
  <p>I want to query it thus: </p>
  
  <pre><code>select count(processed) from dbo.AR_Sale where processed = 0
  </code></pre>
  
  <p>If the result is 0 I want to send an e-mail saying the records are not there.  If greater than zero, I want to proceed with package execution. I am new to SSIS and can't seem to figure out what tool to use for this.  </p>
  
  <p>My package has a data flow item with an OLE DB connection inside it to the database. The connection uses a query to return the records.  Unfortunately, the query completes successfully (as it should) even if there are no records to process.  Here is the query:</p>
  
  <pre><code>Select * from dbo.AR_Sale where processed = 0
  </code></pre>
  
  <p>I copy these records to a data warehouse and then run another query to update the source table by changing the processed field from 0 to 1.<br>
  Any help would be greatly appreciated.</p>