This post is showing you how to connect R language to Microsoft SQL Server.
I used the command below to connect to northwind sample database.
> install.packages(“RODBC”)
> library(RODBC)
> cn <- odbcDriverConnect(connection=”Driver={SQL Server Native Client 11.0};server=localhost;database=NORTHWND;trusted_connection=yes;”)
> dataFetchEUR <- sqlFetch(cn, ‘Products’, colnames=FALSE, rows_at_time=1000)
> View(dataFetchEUR)
![Connect R to Microsoft SQL Server]()
Reference:
I could not use the odbc as stated here https://support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server- .. I have tried it in R 3.4.3 as well as R 3.5.1.
I used RODBC, and it has been working for the 2 mentioned versions.I used the command below to connect to northwind sample database.
> install.packages(“RODBC”)
> library(RODBC)
> cn <- odbcDriverConnect(connection=”Driver={SQL Server Native Client 11.0};server=localhost;database=NORTHWND;trusted_connection=yes;”)
> dataFetchEUR <- sqlFetch(cn, ‘Products’, colnames=FALSE, rows_at_time=1000)
> View(dataFetchEUR)

Reference:
https://www.red-gate.com/simple-talk/sql/reporting-services/making-data-analytics-simpler-sql-server-and-r/






