I have a dataframe (df) with three columns (a,b,c)
I am inserting these values into SQL database using
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)
Source: How to insert a dataframe into a SQL Server table?
My question is what is the update equivalent of this example ? How can i use
cmd <- paste("update MyTable values ", values)
result <- sqlQuery(con, cmd, as.is=TRUE)
I tried sqlSave and sqlUpdate but it got sticky too soon with error messages like missing columns, index etc...so I am falling back to this example above and trying to learn how to use update statements based on that toy dataset. Any help is much appreciated folks.