R: ODBC Copy

sqlCopy {RODBC} | R Documentation

## ODBC Copy

### Description

Functions to copy tables or result sets from one database to another.

### Usage

    sqlCopy(channel, query, destination, destchannel = channel,
            verbose = FALSE, errors = TRUE, ...)

    sqlCopyTable(channel, srctable, desttable, destchannel = channel,
                 verbose = FALSE, errors = TRUE)

### Arguments

`channel, destchannel` | connection handle as returned by `odbcConnect`.
`query` | any valid SQL statement
`destination, srctable, desttable` | character: a database table name accessible from the connected DSN.
`verbose` | Display statements as they are sent to the server?
`errors` | if TRUE halt and display error, else return `-1`.
`...` | additional arguments to be passed to `sqlSave`.

### Details

`sqlCopy` as is like `sqlQuery`, but saves the output of `query` in table `destination` on channel `destchannel`.

`sqlCopyTable` copies the structure of `srctable` to `desttable` on DSN `destchannel`. This is within the limitations of the ODBC lowest common denominator. More precise control is possible via `sqlQuery`.

### Value

See `sqlGetResults`.

### Author(s)

Michael Lapsley and Brian Ripley

### See Also

`sqlQuery`, `sqlSave`

### Examples

    ## Not run: ## example for a l/casing DBMS
    sqlSave(channel, USArrests, rownames = "state")
    query <- paste("select state, murder from usarrests",
                   "where rape > 30", "order by murder")
    sqlCopy(channel, query, "HighRape", rownames = FALSE)
    sqlFetch(channel, "HighRape", rownames = "state", max = 5)
    sqlDrop(channel, "HighRape")

    ## End(Not run)

[Package RODBC version 1.3-16 Index]