title: Output csv file SQL
body: <p>Here is the code I have so far:</p>
  
  <pre><code>DECLARE @bcpCommand varchar(2000)   
  DECLARE @query varchar(2000)
  
  SET @query = 'select job_description from [mainDB].[myschema].[table]'
  SET @bcpCommand = 'bcp " ' + @query + ' "  queryout "c:\test.csv" -T -c -t,'''
  EXEC master..xp_cmdshell @bcpCommand
  </code></pre>
  
  <p>When I run this, I get the following message:</p>
  
  <blockquote>
    <p>NULL<br>
    Starting copy...<br>
    1000 rows successfully bulk-copied to host-file.<br>
    Total received: 1000 1000 rows successfully bulk-copied to host-file.<br>
    Total received: 2000 1000 rows successfully bulk-copied to host-file.<br>
    Total received: 3000 1000 rows successfully bulk-copied to host-file.<br>
    Total received: 4000 1000 rows successfully bulk-copied to host-file.<br>
    Total received: 5000 1000 rows successfully bulk-copied to host-file.<br>
    Total received: 6000<br>
    6564 rows copied.<br>
    Network packet size (bytes): 4096<br>
    Clock Time (ms.) Total     : 16     Average : (410250.00
    rows per sec.) </p>
  </blockquote>
  
  <p>The file doesn't exist in the c drive though. Why doesn't the file show up in the c drive? Am I looking at the wrong place?</p>