title: How to combine two dynamic sql with union ALL
body: <p>I have two dynamic sql queries like this</p>
  
  <pre><code>@sql = 'select productname,year from products'
  
  
  @sql2 = 'select productname,year from products_sample'
  </code></pre>
  
  <p>I need something like this</p>
  
  <pre><code>select @query= (@SQL+'UNION ALL' +@SQL1 )
  </code></pre>
  
  <p>but it's not working </p>
  
  <p>Any help</p>