I'm trying to append records to an existing SQL table using the sqlSave method in the RODBC package.
df <- data.frame(EmployeeID = c(NA, NA, NA), EmployeeName=c("Bob", "Sue", "Jane"))
sqlSave(myconn, dat=df, tablename = "Employees", append = TRUE, rownames = FALSE, colnames = FALSE, verbose = TRUE, safer = TRUE,
addPK = FALSE, typeInfo, varTypes, fast = TRUE, test = FALSE, nastring = NULL)
However, I keep getting the error
[RODBC] Failed exec in Update 23000 544 [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF.
My table should be creating IDs automatically. What gives?
EmployeeIDcolumn from the data.frame? With this method, it looks like you're trying to append NULL values into the EmployeeID column. Better to leave those values unspecified for the append. - MrFlick