sqlFetch {RODBC} | R Documentation |
Read a table of an ODBC database into a data frame.
sqlFetch(channel, sqtable, ..., colnames = FALSE, rownames = TRUE)
channel |
connection handle returned by odbcConnect . |
sqtable |
a database table name accessible from the connected dsn. This should be either a character string or a character vector of length 1. |
... |
additional arguments to be passed to
sqlGetResults . |
colnames |
logical: retrieve column names from first row of table? |
rownames |
either logical or character.
If logical, retrieve row names from the first column
(rownames ) in the table? If character, the column name to
retrieve them. |
sqlFetch
retrieves the the entire contents of the table
sqtable
. Rownames and column names are restored as indicated.
It tries to cope with the peculiar way the Excel ODBC driver handles table names.
Useful additional parameters to pass to sqlGetResults
include
max
:{nullstring}:
{character string to be used when reading
SQL_NULL_DATA
character items from the database.}
na.strings
:NA
when reading character data.as.is
:sqlGetResults
.dec
:
A data frame on success, or a character or numeric error code (see
sqlQuery
).
Michael Lapsley and Brian Ripley
sqlSave
, sqlQuery
,
odbcConnect
, odbcGetInfo
library(RODBC) data(USArrests) channel <- odbcConnect("test", "", "") # userId and password sqlSave(channel, USArrests, verbose = TRUE) sqlFetch(channel, "USArrests") # get the lot sqlDrop(channel, "USArrests") odbcClose(channel)