title: How to escape double quotes in bcp sql query in stored procedure sql server
body: <p>The following is my stored procedure code:</p>
  
  <pre><code>Alter PROCEDURE [dbo].[ConvertToFile]
  
      @TempFileName varchar(8000)
  AS
  BEGIN
      SET NOCOUNT OFF;
  
      DECLARE @bcpFileCmd varchar(8000)
  
  
  SET @bcpFileCmd= 'bcp "SELECT id,full_Name,message from NotesTable " queryout '+@TempFileName+' -t, -c -T'
  
      EXEC master..xp_cmdshell @bcpFileCmd
  
  END
  </code></pre>
  
  <p>BCP dumps all the data from NotesTable in file. But I need to enclose the message results with double quotes. The datatype for message field is text. I'm not able to append it in select query in BCP. </p>