KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to upload a dataframe to a SQL Server table, I tried breaking it down to a simple SQL query string.. library(RODBC) con <- odbcDriverConnect("driver=SQL Server; server=database") df <- data.frame(a=1:10, b=10:1, c=11:20) values <- paste("(",df$a,",", df$b,",",df$c,")", sep="", collapse=",") cmd <- paste("insert into MyTable values ", values) result <- sqlQuery(con, cmd, as.is=TRUE) ..which seems to work but does not scale very well. Is there an easier way?
Tags (comma-separated)
Save Edits
Cancel