title: Paste SQL Query output with line breaks into single Excel cell
body: <p>I'm trying to write SQL code that pulls data from more than one field and displays it in a single field, but on multiple lines.  The goal is outputting to Excel retaining multiple lines <em>in a single cell</em>.  Our current procedure is just using Excel to concatenate two fields into one cell with carriage returns, but I would like to have SQL do that if possible.</p>
  
  <p>For example:</p>
  
  <pre><code>DECLARE @text NVARCHAR(100)
  SET @text = 'This is line 1.' + CHAR(13)  + 'This is line 2.'
  print @text
  </code></pre>
  
  <p>Displays this:</p>
  
  <pre>
  This is line 1.   
  This is line 2.</pre>
  
  <p>Changing to a Select:</p>
  
  <pre><code>DECLARE @text NVARCHAR(100)
  SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
  select @text
  </code></pre>
  
  <p>Displays this:</p>
  
  <pre>This is line 1. This is line 2.</pre>
  
  <p>I want to then copy and paste that output into Excel and have the data appear in a single cell so this is all in one cell:</p>
  
  <pre>
  This is line 1.   
  This is line 2.</pre>