Connecting R to a SQL query
R has a package called RODBC
that provides access to databases through an ODBC interface. We will continue to use RStudio as our IDE of choice for R. We first run scripts to install and call the RODBC
library:
install.packages('RODBC') library('RODBC')
The next step is to create an R connection that will link to the SQLBI
OBDC connection we just created:
connection_SQLBI<-odbcConnect('SQLBI')
If we are interested in obtaining the connection details for the connection, we can run the following script:
connection_SQLBI
The output is the parameters for the connection, as seen in the following screenshot: