I need to append a dataframe to a table in SQL Server called UnderPerformers. However, when I run
sqlSave(cnl, Under_performing, tablename = "UnderPerformers",
rownames = FALSE, append = TRUE)
the table is created in SQL Server but no rows are transferred. UnderPerformers looks like this:
Turbine P Value Percent Energy Lost Start Date End Date
1 CPP01-2A 0.00545027363873885 17.51797 2016-03-15 2016-04-14
2 CPP01-30 0.000250295501806691 22.55331 2016-03-15 2016-04-14
3 CPP01-11 0.00709715868534389 16.94138 2016-03-15 2016-04-14
5 CPP01-23 0.00335499430062067 18.31097 2016-03-15 2016-04-14
I've tried closing and re-opening the rodbconnection right before sqlSave() but run into the same problem. If I delete the table in SQL Server and run just
sqlSave(cnl, Under_performing, tablename = "UnderPerformers", rownames = FALSE)
I get
Error in sqlSave(cnl, Under_performing, tablename = "UnderPerformers", : table ‘UnderPerformers’ already exists
I'm confused why I get this error even though I've deleted the table in SSMS.
Any help on how to correctly save and append this data to the SQL Server table would be much appreciated.