Thank you Bart for your idea, the thing is that I have a large number of
tables and I would like to avoid having to pull them at all.

I currently have a list that I use as a lookup table in a loop with an if
else statement to sort between tables I want to sqlFetch (take everything)
and tables where I sqlQuery (only want part of the table). The names of the
list itself constitute a positive definition of what tables I want to pull.

Here in a reduced illustrative example of what I am doing. My problem is
still that I would like to make negative selection so I get everything
except 'V1010' and 'V1012' in table 3, and so forth (please see below).

######   illustrative R example   ######

q.lookup <- list(Table3 =   c('V1010', 'V1012'),
                      Table7 =   c('V1040', 'V1052'),
                      Table9 =   'ALL')
dfn <- list()

for(i in names(q.lookup)) {
  if (q.lookup[[i]][1]=="ALL") {
     query <- names(q.lookup[1])
     table.n <- sqlFetch(mdbConnect, query)
  } else if (q.lookup[[i]][1]!="ALL") {
     query <- paste("select", paste(q.lookup[[i]], collapse=", "), "from",
names(q.lookup[i]))
     table.n <- sqlQuery(mdbConnect, query)
  } else print("your SQL call is gone haywire, fix it in line 193-204")
  dfn[[i]] <- table.n
}

###   end of illustrative R example   ####

I could use your solution, I think, but if at all possible I would prefer
to figure out how to make a negative SQL statement (I still imagine that
there is some reverse function of the SQL select statement somewhere out
there).

With hight hopes.

Eric

On Wed, Mar 28, 2012 at 2:24 AM, Bart Joosen <bartjoo...@hotmail.com> wrote:

> What you can do: "SELECT top 1 * FROM your_table;"
> Use this selection to find all your column names in R
> then paste everything together without the names you don't want and then
> run
> your query.
>
> Bart
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Is-it-possible-to-de-select-with-sqlQuery-from-the-RODBC-library-tp4511189p4511800.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to