[R] syntax to connect to linked SQL server using RODBC

Varun Sinha sinha.varuna85 at gmail.com
Tue Sep 13 16:02:20 CEST 2016


Hi All,

I would like to know how to connect to a "linked server" from R. I find the
linked server under Server Objects > Linked Servers on SQL management
studio.

Here is the current way I am using to connect to the server:

dbhandle <- odbcDriverConnect('driver={SQL
Server};server=servername;database=databasename;trusted_connection=true')

table1 <- as.data.table(sqlQuery(dbhandle, 'select a, b from table1'))

Could you please let me know the syntax to do the same but with the linked
server instead? I would like to connect to a database on the linked server
and run the query to pull data.

Thank you for your help.

Best regards,
Varun

	[[alternative HTML version deleted]]



More information about the R-help mailing list