Randy Minder Randy Minder - 1 year ago 86
R Question

RODBC - sqlSave - Append Operation Crashes R

I'm trying to save the following dataframe to a SQL Server 2014 table:

Observations: 1
Variables: 4
$ ValidationDate <chr> "2016-08-23"
$ DataType <chr> "Panel"
$ MissingData <chr> "{\"SubId\":[160823030720,160823030721,160823030722,160823030723,16082303072...
$ Comments <chr> "Missing in ODS"

I'm executing the following R code:

sqlSave(odsHandle, df, tablename = "Utility.DailyDataValidation", append = T)

When this lines executes, there is a pause for perhaps 15 seconds and then R crashes with the following error:

enter image description here

Answer Source

sqlSave with append=TRUE often fails to work, so you will often have to write your own insert statement along the lines of

sqlQuery(odsHandle,paste0("insert into Utility.Daily.Data.Validation values (",*paste values here separated by a comma*,")")