Re: [R] RODBC / odbcConnectExcel Issue

From: James W. MacDonald <jmacdon_at_med.umich.edu>
Date: Fri, 04 Apr 2008 09:18:45 -0400

Hi Vishal,

Vishal Belsare wrote:
> Can someone throw light on the following problem I am having with RODBC?
> There's an Excel file I am trying to read from, it has one sheet named
> 'nameclass'.
>
> Thanks in anticipation.
>
>
> Vishal Belsare
>
>

>> library(RODBC)
>> con = odbcConnectExcel(file.choose())
>> tbls <- sqlTables(con)
>> tbls

> TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS
> 1 T:\\data\\in\\nameclass <NA> nameclass$ SYSTEM TABLE <NA>
>
>> qry = paste("SELECT * FROM '",tbls$TABLE_NAME[1],"'",sep="")
>> result = sqlQuery(con,qry)
>> result

> [1] "[RODBC] ERROR: Could not SQLExecDirect"
>
> [2] "42000 -3506 [Microsoft][ODBC Excel Driver] Syntax error in FROM
> clause."

You want your table name to be wrapped in []. In this case the query should be

SELECT * FROM [nameclass$]

Best,

Jim

>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 04 Apr 2008 - 13:20:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Apr 2008 - 15:00:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive