title: How to generate a csv file using select query in SQL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/425379/how-to-export-data-as-csv-format-from-sql-server-using-sqlcmd">How to export data as CSV format from SQL Server using sqlcmd?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to generate CSV file using select query in SQL-server.  </p>
  
  <p>The code below is working correctly in mySQL:</p>
  
  <pre><code>select * into outfile 'd:/report.csv' fields terminated by ',' from tableName;
  </code></pre>
  
  <p>It generated the CSV file.</p>
  
  <p>Does anybody know how  can I create a CSV file using select query in SQL-server?</p>