title: Using SQL Script, create a text file with new line character
body: <p>I am trying to create a text file that includes line breaks. I have this code:</p>
  
  <pre><code>DECLARE @Text AS VARCHAR(100)
  DECLARE @Cmd AS VARCHAR(100)
  
  SET @Text = 'This is my text line 1 (supposed to be new line character) This is line2'
  SET @Cmd ='echo ' + @Text + ' &gt; C:\FileStore\test.txt'
  
  EXECUTE Master.dbo.xp_CmdShell  @Cmd, NO_OUTPUT
  </code></pre>
  
  <p>What should i use to have a new line character on the text file so that the output should be</p>
  
  <pre><code>This is my text line 1
  This is line2
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  I've tried this as per suggestions</p>
  
  <pre><code>SET @Text = 'This is my text line 1' + char(13) + char(10)+ 'This is line2'
  </code></pre>
  
  <p>But with this, it won't create the txt file anymore</p>
  
  <p>Thanks</p>