title: Use table variable in control and data flow
body: <p>Assume the following scenario:</p>
  
  <p>All data are in Sql Server tables.</p>
  
  <p>1) An Execute SQL Task to determine if there are records to process by running a select against Table1.</p>
  
  <p>2) If there are, an Execute SQL Task to truncate Table2.</p>
  
  <p>3) A Data-flow task to Load Table2 with the results from the select against Table1.</p>
  
  <p>Now, I can do that easily in a stored procedure, but am required to do it in SSIS.</p>
  
  <p>So far, in the control flow, I've run my select and stored the results in a table variable, lets call it @ResultSet, and just for good measure, I have also created an object-type variable, let's call it MyResults also holding the resultset.</p>
  
  <p>To avoid truncation of Table2 if @ResultSet is empty, I then count the number of records in @ResultSet and raise an error if the count is zero, effectively aborting the package.</p>
  
  <p>Normally this is not the case, and instead of starting my Data-flow by running the same query against Table1 all over again, I would now like to access either my @ResultSet or my
  MyResults object like any other data source.</p>
  
  <p>The latter should be possible using a scripting task, but I really, really don't want to go down that road.</p>
  
  <p>Whether I can use my @ResultSet or come up with an entirely different approach due to your input, that is the question.</p>
  
  <p>TIA.</p>