If I want to connect R to a database, do I still need to install driver for R user?
I had done successful connection with server but unable to read/write/fetch the tables.
library(odbc)
con <- dbConnect(odbc::odbc(),
.connection_string = 'driver={SQL Server};server=DW01;database=AF_DW;trusted_connection=true')
Now I can see AF_DW in RStudio connections.
dbListFields(con, "Visits")
I can see all the variables in the table "Visits"
data <- dbReadTable(con, "Visits")
Got an Error: nanodbc/nanodbc.cpp:1655: 42000: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Visits'. [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. 'SELECT * FROM "Visits")
data3 <- dbGetQuery(con, "SELECT * FROM Visits")
Got same error
data4 <- dbSendQuery(con, "SELECT * FROM Visits")
Got same error
con_in_R <- dbFetch(dbSendQuery(con,"SELECT * FROM Visits"))
Error in (function (cond) : error in evaluating the argument 'res' in selecting a method for function 'dbFetch': nanodbc/nanodbc.cpp:1655: 42000: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Visits'. [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. 'SELECT * FROM Visits'
Appreciate your help. Thank you.