title: Running SQL query through RStudio via RODBC: How do I deal with Hash Tables?
body: <p>I've got a very basic SQL query that I'd like to be able to view in R.</p>
  
  <p>The trouble is, I need to be able to reference a #table:</p>
  
  <pre><code>    select
      RAND(1) as random
      into #test
  
      select * from #test
  </code></pre>
  
  <p>Is this possible, or will I need to create permanent tables, or find some other work around?</p>
  
  <p>I currently do this via a RODBC script which allows me to choose which SQL file to run:</p>
  
  <pre><code>    require(RODBC)
      sql.filename &lt;- choose.files('T:\\*.*')
      sqlconn &lt;- odbcDriverConnect("driver={SQL Server};Server=SERVER_NAME;Trusted_Connection=True;")
      file.content &lt;- readLines(sql.filename)
      output &lt;- sqlQuery(sqlconn, paste(file.content[file.content!='--'],collapse=' '))
      closeAllConnections()
  </code></pre>
  
  <p>Do you have any advice on how I can utilise #tables in my SQL scrips in R?</p>
  
  <p>Thanks in advance!</p>