How do you connect dbplyr to linked sql servers

How do you create a tbl object that connects to a linked server?

I love using dbplyr to work with databases and often setup table objects like this with no problem.

But I can't seem to add a linked server name.

This code works but I want to create a tbl and not pull back a dataframe.
DBI::dbGetQuery(con,'select * from linked_server.database.schema.table')

I think the issue is something to do with each object needing to be quoted but I can't quite figure out how to do this myself.

Any help would be much appreciated.

This took me ages to figure out but can hopefully help others in the same situation

This works to create a lazy data frame from a linked server table
tbl(con, sql("select * from linked_server.database.schema.table")

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.