使用 RODBC 包将数据框导出到 SQL 服务器 [英] Export data frame to SQL server using RODBC package
问题描述
我在 R 中使用 RODBC
包从 SQL Server 数据库导入/导出数据帧.虽然导入没有问题.我不知道如何将数据框的内容导出到现有的 SQL 表中.
I am using RODBC
package in R to import / export data frames from SQL Server database. While there is no problem in importing. I dont know how to export the contents of a data frame into an existing SQL table.
我正在尝试使用包中提供的 sqlQuery()
函数,但我不确定如何在表中插入多条记录.
I am trying to use sqlQuery()
function available in the package, but I am not sure how to insert multiple records in the table.
有关如何插入行的示例会有所帮助我已经确保我的表格和数据框的列是相同的.
A sample on how to insert the rows will be helpful I have ensured that columns of my table and data frame are same.
推荐答案
使用 sqlSave
和 append 属性.请参阅下面的代码:
Use sqlSave
with append property. See my code below:
sqlSave(uploaddbconnection, outputframe, tablename =
"your_TableName",rownames=FALSE, append = TRUE)
这篇关于使用 RODBC 包将数据框导出到 SQL 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!