I'm trying to fetch/update a table in a sql database using R package RODBC.
OPTION 1 for SQL query works fine, but how to apply the same logic and refer to specific database (there are multiple) in OPTION 2 (not working) for fetch/update/save?
REF option brings the table from the default database (ie. equivalent to XXX, not XXX_Test)
channel <- odbcConnect(dsn="XXX")
# OPTION 1
# sql statements
Table_sql <- "select * from XXX_Test.dbo.Table"
# query the DB
Table <- sqlQuery(channel, query=Table_sql, as.is = TRUE)
#OPTION 2
Table2<-sqlFetch(channel,"XXX_Test.dbo.Table")
#Error in odbcTableExists(channel, sqtable) :
# ‘XXX_Test.dbo.Table’: table not found on channel
### REF
Table3<-sqlFetch(channel,"Table")
Thank you for your help