Reading data from Microsoft SQL Server into R

前端 未结 7 592
长发绾君心
长发绾君心 2021-02-01 02:17

Is it possible to read the data stored in MS SQL server from R interface?

If it is I would be also thankful if anyone could show the way to do it.

7条回答
  •  天涯浪人
    2021-02-01 02:56

    You can connect to SQL server using DBI package, which I think works better than RODBC. DBI is a database interface package for relational databases. for SQL I use it along with odbc package as in the example below.

    Visit this page for full details: Database Queries with R

    An example would be as follows

    library(DBI) library(odbc) con <- dbConnect(odbc::odbc(), .connection_string = "driver={SQL Server}; server= ServerName; database=DatabaseName; trusted_conncetion=true")) dbGetQuery(con,'Select * from Table')

提交回复
热议问题