I use the dplyr (0.7.0), dbplyr (1.0.0), DBI 0.6-1, and odbc (1.0.1.9000). I would like to do something like the following:
db1 <- DBI::dbConnect(
odbc::odbc(),
Driver = "SQL Server",
Server = "MyServer",
Database = "DB1"
)
db2 <- DBI::dbConnect(
odbc::odbc(),
Driver = "SQL Server",
Server = "MyServer",
Database = "DB2"
)
x <- tbl(db1, "Table1") %>%
dplyr::left_join(tbl(db2, "Table2"), by = "JoinColumn")
but I keep getting an error that really has nothing to do with it. When I use it show_query, it looks like the code is trying to create an SQL query that joins two tables without regard to individual databases. In the documentation for dplyr::left_joinI also tried:
x <- tbl(db1, "Table1") %>%
dplyr::left_join(tbl(db2, "Table2"), by = "JoinColumn", copy = TRUE)
But no changes to the exit message or error. Is there any other way to combine tables from separate databases on one server?
source
share