[R] RODBC: How to Retrieve a Column as Rownames?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 1 11:02:31 CET 2006


On Wed, 1 Feb 2006, Markus Preisetanz wrote:

> Dear Collegues,
>
> when using sqlQuery from the package RODBC I always get a data frame with automatically generated rownames, even if:
>
> *  the first column of the query is called rownames using "Select ... AS rownames, ... From ..."
>
> *  and: the values from this column are unique
>
> *  and: the values are inevitably forced to character data with e.g. " 'rn_' + CAST(xy AS NVARCHAR) "
>
> It works with sqlFetch but I would have to define a view for every 
> query. Does anybody know help?

Well, you use ?sqlQuery to find out, as I just did.  What is so hard about 
that?

This is documented feature of sqlFetch, and not mentioned at all as
supported by sqlQuery.  As sqlFetch is a wrapper for sqlQuery you can just
write your own wrapper based on it.

The (unacknowledged) maintainer of RODBC, and author of this feature.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list