I am trying import tables in SQL Server 2017 into R. So, I wrote down these codes. Connection seems okay. But when I import tables I get an error and a warning message like below. I can solve this problem by write sqlQuery or dbGetQuery in R but I would like to understand what is problem with dbReadTable. Finally I kindly ask you help me to list tables within particular schema in R.
install.packages("RODBC")
library(DBI)
library(RODBC)
install.packages("odbc")
library(odbc)
# Making proper conection.
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "WINDOWS-M6QDHVB\\SQLEXPRESS",
Database = "AdventureWorks2017",
Trusted_Connection = "True")
#Import data wihtin the table into R.
dbReadTable(con, SQL("HumanResources.Department"))
dbReadTable(con, SQL("HumanResources.Employee"))
Warning message:
In dbClearResult(rs) : Result already cleared
Error in result_fetch(res@ptr, n) :
nanodbc/nanodbc.cpp:3186: 07009: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index