What package to connect R 3.4.3 to MS SQL Server?

What package can I use to connect R version 3.4.3 with Microsoft SQL Server? I found some posts on the internet which suggested to use install.packages ("RODBC") for R 3.4.3 but it didn't work for me.

Capture

1 Like

You could try looking through this resource: https://db.rstudio.com

You should be able to set up an odbc connection for MS SQL Server from there: https://db.rstudio.com/odbc/

After installing packages correctly you should be able to do something like:

rsqlserver <- dbConnect(RSQLServer::SQLServer(), server = "SQLServer")

Otherwise try the instructions found here: https://db.rstudio.com/databases/microsoft-sql-server/

See if you can get any of this stuff to work and I'd be happy to help more from there!

For package installation I would think this should do the trick:

install.packages("DBI")
install.packages("RODBCDBI")
library(DBI)
library(RODBCDBI)

Thanks for your help. I tried both packages but only DBI was installed successfully while RODBCDBI only works for 3.4.4 (mine is 3.4.3).

After installing package DBI, I tried this script but it gave me error:
SQLServer <- DBI::dbConnect(dbDriver("SQL Server Native Client 11.0"), "server=xxxxxx;database=xxxx;user=xxxx;password=xxxxx;trusted_connection=yes")

The error is: Couldn't find driver SQL Server Native Client 11.0