I am trying to append records from a dataframe in R to an established SQL data table using the odbc::dbWriteTable() function. This is a function I use for many workflows to append records to various database tables.
Specifically: odbc::dbWriteTable(connection, DBI::SQL(glue("{database}.{schema}.{table}")), value = dataframe, append = TRUE)
The dataframe and the target SQL table share the same column names and variable types.
However, when I attempt to run the function and append the data records, I receive the following error:
Error in result_insert_dataframe(rs@ptr, values, batch_rows) : nanodbc/nanodbc.cpp:####: ######: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'row_names'. [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared.
The dataframe contains no row names. Why is the column name "row_names" being generated, and is there a way to ensure this column name is not generated? Many thanks in advance for any suggestions!