title: How to concatenate all columns in a select with SQL Server
body: <p>I need my select to have a pattern like this: </p>
  
  <pre><code> SELECT '&lt;text&gt; ' + tbl.* + ' &lt;/text&gt;' FROM table tbl;
  </code></pre>
  
  <p>The ideal solution would have all the columns separated by a comma in order to have that output:</p>
  
  <p>SQL result for Table 1 with two columns:</p>
  
  <pre><code>'&lt;text&gt;col1, col2&lt;/text&gt;'
  </code></pre>
  
  <p>SQL result for Table 2 with three columns:</p>
  
  <pre><code>'&lt;text&gt;col1, col2, col3&lt;/text&gt;' 
  </code></pre>
  
  <p>I tried to use the <code>CONCAT(...)</code> function like this:</p>
  
  <pre><code>SELECT CONCAT('&lt;text&gt;', tbl.*, '&lt;/text&gt;')
  FROM table2 tbl
  </code></pre>
  
  <p>But I understand it is not so simple because the variable number of columns.</p>
  
  <p>Is there any simple solution to address that problem?</p>
  
  <p>I am using SQL Server 2008 R2.</p>