title: SSIS Execute SQL not returning result
body: <p>Using a Execute SQL Task to find if any records were loaded during a ETL. For some reason Record count is always 0. The batch_Id is correct as you can see in the watch window. I have tried everything I can think of. Including making batchid a parameter and using ? in the query. Using a ADO Data source. If I take the query and execute it on my server it returns a record count, so I know there are records. The execution results doesn't show any errors. I have tried everting I can think of. Please help. Thank you in advance.</p>
  <p>It would be easy to test just create a table 'Trace_Return_BRE' with a few records with one field &quot;Batchid&quot; = '2102010900'</p>
  <p>Task: Get record Count<br>
  Conn Type: OLE DB<br>
  Conn: SQLServer<br>
  SQL Source: Direct Input</p>
  <p>SQL Statement (from Expression)</p>
  <pre><code>DECLARE @BatchId as VARCHAR(10) 
  
  SET @BatchId = '2102010900'
  
  SELECT COUNT(*) As RecCnt 
  FROM  dbo.Trace_Return_BRE 
  WHERE (BatchId = @BatchId) 
  </code></pre>
  <p>Parameter Mapping: None<br>
  Result Name : 0<br>
  Variable Name : User::RecordCount <br>
  Expression: SQLStatmentSource</p>
  <blockquote>
  <p>&quot;DECLARE @BatchId as VARCHAR(10)<br />
  SET @BatchId = '&quot; +
  @[User::Batch_Id] + &quot;'</p>
  <p>SELECT COUNT(*) As RecCnt  FROM  dbo.Trace_Return_BRE  WHERE (BatchId
  = @BatchId)&quot;</p>
  </blockquote>
  <hr />
  <p>ETL Variable
  User::Batch_ID String = 2102010900</p>
  <p><a href="https://i.stack.imgur.com/cgmMz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cgmMz.png" alt="enter image description here" /></a></p>