title: Run SQL query based on the previous output
body: <p>The following query results only "Operation is Success" whilst my aim is to run the "Select" statement listed under IF TRUE condition:</p>
  
  <pre><code>DECLARE @TOTAL int
  
  Select @TOTAL = count(barcode) 
  from domain_Media 
  where ( (librarySlotNumber &gt; -1) 
    AND (UPPER(volumePoolName) LIKE UPPER('scratch%')) 
    AND (id LIKE '05%' or id LIKE 'DX%') 
    AND (masterServerId = 17785613) )
  
  IF (@TOTAL &gt; 5)
  BEGIN
    select * 
    from domain_Media 
    where (masterServerId = 17785613)
  END
  </code></pre>
  
  <p>Where am I going wrong?</p>