0

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.

Parfait
  • 104,375
  • 17
  • 94
  • 125
DScales
  • 1
  • 1
  • Please check spelling of dataframes. Does it match MSSQL table? Either an underscore is used in R or not. How do you delete the table? With a `DROP` or `DELETE` statement or SSMS's GUI? Can you provide full code of connection and query block and not in snippets? – Parfait Aug 03 '16 at 22:42
  • Possible duplicate of [RODBC sqlSave table creation problems](http://stackoverflow.com/questions/23913616/rodbc-sqlsave-table-creation-problems) – Liesel Aug 04 '16 at 01:00
  • Thanks for the help! Turns out the tables were being saved just under the wrong database in SSMS. closing and re-opening the connection was the issue. – DScales Aug 05 '16 at 14:05

0 Answers0