Nitin
Nitin

Reputation: 1

Connect R to local sql server using RSQLServer package

I am trying to connect R and local sql server i.e. windows authentication based using dplyr package as I have large data set to work upon and cannot pull all of them into R. Can someone please help me with the connection.

I believe RSQLServer::src_sqlserver under RSQLServer package would help but I am not able to do so.

I tried using this command:

install_github('rsqlserver', 'agstudy',args = '--no-multiarch')

but I get an error message

:ERROR:
dependency 'rClr' is not available for package 'rsqlserver'.

Please help

Upvotes: 0

Views: 1075

Answers (1)

Zahiro Mor
Zahiro Mor

Reputation: 1718

the error message you got is caused by the inability to install a the rClr package. however - you can try the following method:

a. install package 'RODBC' from cran and attach it:

install.packages("RODBC")

library("RODBC")

b. define a connection: (change to your server's IP or localhost)

connection <- odbcDriverConnect("driver=SQL Server; server=XXX.XXX.XXX.XXX; database=[your db name]; trusted_connection=true")

c. type your query using the defined connection:

sqlQuery(connection , 'select * from information_schema.tables')

cool?

Upvotes: 1

Related Questions