Search code examples
rrodbc

RODBC sqlSave() and mapping column names


I've a question about using sqlSave. How does R map RODBC data in the data frame to the database table columns?

If I've a table with columns X and Y and a data frame with columns X and Y, RODBC puts X into X and Y into Y (I found out by trail-and-error). But can I explicitly tell R how to map data.frame columns to database table columns, like put A in X and B in Y.

I'm rather new to R and think the RODBC manual is a bit cryptic. Nor can I find an example on the internet.


Solution

  • I'm now doing it this way (maybe that's also what you meant):

    colnames(dat) <- c("A", "B")
    sqlSave(channel, dat, tablename = "tblTest", rownames=FALSE, append=TRUE)
    

    It works for me. Thanks for your help.