title: How can I export a mySQL #temp table to a .csv file within script?
body: <p>I'd like to write a script that allows me to export .csv files from 15-20 temporary tables I created, using a script instead of having to copy and paste in a separate <code>.csv</code> file and then save them down.</p>
  
  <pre><code>:!!sqlcmd -S server -d database-E -Q "SET NOCOUNT ON 
  SELECT * FROM TABLE" -o "C:\Users\name\Documents\folder\filename.csv"
  -W -w 1024 -s ","
  </code></pre>
  
  <p>I've tried this, which works (not formatting correctly) but it doesn't seem to be work at all for a temp table; the <code>.csv</code> file contains this.</p>
  
  <pre><code>Msg 208  Level 16    State 1     Server SERVERNAME
  Invalid object name '#TEMPTABLE'.       
  </code></pre>
  
  <p>I cannot obtain "elevated privileges" to be able to use BCP export, because I cannot write a stored procedure, create a new database, or access the command line. Is there a workaround for this?</p>