I am trying to use temp tables in an sql codechunk in rstudio.
An example: When I select one table and return it into an r object things seem to be working:
```{sql  ,  output.var="x",  connection='db'    }
  SELECT count(*) n
    FROM origindb
```
When I try anything with temp tables it seems like the commands are running but returns an empty r data.frame
```{sql  ,  output.var="x",  connection='db'    }
  SELECT count(*) n
    INTO #whatever
    FROM origindb
  SELECT *
   FROM #whatever
```
My impression is that the Rstudio notebook sql chunks are just set to make one single query. So my temporary solution is to create the tables in a stored procedure in the database. Then I can get the results I want with something simple. I would prefer to have a bit more flexibility in the sql code chunks.
my db connection looks like this:
```{r,echo=F}
db <- DBI::dbConnect(odbc::odbc(),
                      driver = "SQL Server",
                      server = 'sql',
                      database = 'databasename')
```
 
     
     
    