I am trying to export an R dataframe (that I had previously created using a SQL query) to SQL in order to perform a merge (JOIN) with data tables on a SQL server.
Specifically, if mydat is a dataframe in R, I would like to be able to do something along the following lines
library('RODBC')
edw = odbcConnect(<some sql server>)
new_mat = sqlQuery(edw,"SELECT
db.code1
db.code2
FROM mydat as a
JOIN SQLServer_Tables.Table1 as fd on fd.codenew=a.codenew and fd.codenew2 = a.codenew2q
"
)
The problem is that I don't know how to get the R data frame "mydat" into SQL as a suitable object. I did find some old stackoverflow threads about exporting R objects (strings, vectors) into SQL, but none of them seem to work on the data frame.