title: Concatenate column values in SQL Server
body: <p>I want to select two columns (first and last name) from a database, combine them into one, and stick them into a data set to be displayed in a datagrid. I also need to add a space between them for formatting.</p>
  
  <p>My normal SQL statement:</p>
  
  <pre><code>SELECT first_name + ' ' + last_name as userName from Table
  </code></pre>
  
  <p>My current VB statement:</p>
  
  <pre><code>strSQL = "SELECT first_name + ' ' + last_name as userName from Table"
  </code></pre>
  
  <p>When I attempt to do this, my application throws the following error: <code>System.Data.SqlClient.SqlException: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.</code></p>
  
  <p>EDIT: For those asking about the database and/or if this is the correct query, if I format my VB query as follows:</p>
  
  <pre><code>strSQL = "SELECT first_name + last_name as userName from Table"
  </code></pre>
  
  <p>I get the proper results, but then the column looks like <code>FirstLast</code> and is very difficult to read.</p>
  
  <p>I'm guessing there's something small I'm missing on how to do this properly within VB. Can anyone advise?</p>
  
  <p>Things I've tried:</p>
  
  <pre><code>strSQL = "Name = TU1.first_name + ' ' + TU1.last_name"
  </code></pre>
  
  <p>This throws the same error. However...</p>
  
  <pre><code>strSQL = "Name = TU1.first_name + '' + TU1.last_name"
  </code></pre>
  
  <p>gives me a result of <code>First'Last</code></p>