Connection issues. R to MS SQL Server
During a recent project I had to connect an R instance on a windows virtual machine provided by a client to their MS SQL Server. I have connected to many other data sources in the past, but I have not had to work with windows for a long time. It is much different than the typical setup in Linux. I am forgetting all the ways to do things. Non the less, I came across many sites that walked me through setting up a user DSN and having it manage my connection to the database. However, I still needed to connect R to MS SQL Server. This required my using the RODBC package.
After a couple of hours of reading the documentation and thank you stack overflow. I have it working. This article was most helpful.
library(RODBC)
con <- odbcDriverConnect('driver={SQL Server};server=mysqlhost;database=mydbname;trusted_connection=true')
res <- sqlQuery(con, 'select * from information_schema.tables')