title: Subquery Select as field in SQL- Error
body: <p>I needed to display the subquery results as field and exporting to csv using BCP.</p>
  
  <p>This is my query.</p>
  
  <pre><code>SELECT DISTINCT 
      NAME [NAME],
      CODE [CUSTOMER CODE],
      FROMDATE [FROMDATE],
      TODATE [TODATE]
  INTO
      ##temp 
  FROM
      (SELECT DISTINCT 
           g.NAME AS NAME,
           g.ACCOUNTNUM AS CODE,
           d.FROMDATE, d.TODATE
       FROM 
           GeneralInfo g 
       INNER JOIN 
           DateInfo d ON g.id = d.generalId)
  </code></pre>
  
  <p>So whenever I exported to CSV the file format was as expected due to name field. I needed to enclose the field with "". But somehow I ended up with an error. Please advise</p>