title: How do you use a cursor to combine data in a Union All?
body: <p>I have a list of databases, say 'database1, database2, database3'. Etc.</p>
  
  <p>At the moment I am querying my results by doing</p>
  
  <pre><code>select column1 from database1..tableA
  union all
  select column1 from database2..tableA
  union all 
  select column1 from database3..tableA
  </code></pre>
  
  <p>Is there a better way of doing this using sp_foreachdb or a cursor with a list of databases?</p>