sqlFetch Table not found error
Asked Answered
A

1

0

After I use

cn<-odbcConnect(...)

to connect to MS SQL Server. I can successfully get data using:

tmp <- sqlQuery(cn, "select * from MyTable")

But if I use

tmp <- sqlFetch(cn,"MyTable") 

R would complain about "Error in odbcTableExists(channel, sqtable) : table not found on channel". Did I miss anything here?

Aporia answered 30/9, 2014 at 21:43 Comment(2)
What is the output of sqlTables(cn)?Westing
What is the result of attributes(cn)?Bromo
A
1

Assuming you work on Windows OS. When you define your "dsn" in Control panel > Administrative tools > System and Security > Data Sources (ODBC), you have to select a database as well. If you do that your code should work as expected.

So, the problem is not in your R code, but in your "dsn" string that in my opinion does not contain the reference to a database which is needed.

Avellaneda answered 1/10, 2014 at 7:55 Comment(1)
Thanks. I just kept clicking "Next" without selecting a default database in one the process. It works now.Aporia

© 2022 - 2024 — McMap. All rights reserved.