Learn R Programming

RODBC (version 1.0-2)

sqlFetch: Reading Tables from ODBC Databases

Description

Read a table of an ODBC database into a data frame.

Usage

sqlFetch(channel, sqtable, ..., colnames = FALSE, rownames = TRUE)

Arguments

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.

Details

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 [object Object],[object Object] A data frame on success, or a character or numeric error code (see sqlQuery). sqlSave, sqlQuery, odbcConnect, odbcGetInfo [object Object],[object Object] 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) IO database