Re: [R] Using RODBC to use SQL queries

From: Albin Blaschka <>
Date: Wed, 23 Jul 2008 15:44:11 +0200

Megan J Bellamy schrieb:
> After that I'd like to use the odbcQuery function and the SQL statement:
> SELECT * FROM table_name WHERE SAMPLE_YEA LIKE "1965%"
> According to the RODBC PDF, the odbcQuery command should accept any
valid SQL statement. Is there something wrong with my syntax? I have tried a few things, like attaching the tables to the data frame but with no luck. According to the PDF, I should be able to use this argument:
>> odbcQuery(channel, query, rows_at_time,=attr(channel, "rows_at_time"))
> I have also tried to use arguments like:
>> sqlColumns(channel, "SAMPLE_YEA")
> but with no luck. Any help with this would be much appreciated!
Thanks in advance,


which error message do you get, what does not work?

Just a blind guess:
Maybe the problem lies within the % - Sign? Try to double it - ...LIKE "1965%%"

Here an working RODBC - Example:

channel <- odbcConnect("myODBC", uid="myUser", case="tolower") sql <- "select x,y,z from mytable"
myresult<- (sqlQuery(channel, sql))

Best wishes,

| Albin Blaschka, Mag. rer.nat - Salzburg, Austria
| It's hard to live in the mountains, hard, but not hopeless!

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 23 Jul 2008 - 15:26:54 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 Wed 23 Jul 2008 - 16:32:10 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive