简体   繁体   中英

R RODBC sqlUpdate or sqlQuery

I am trying to insert a dataframe into a sql table. The sqlUpdate code gives a inherits(channel, "RODBC") channel is missing error Insertdata<-sqlUpdate(DBcon, df, tablename = "DataQuality", sqlColumns(special=FALSE)) My second attempt was this

Insertdata<-sqlQuery(DBcon,paste("insert into DataQuality", df, sep = ""))

sqlQuery shows an error of

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'Nothing to add'

." (this is the first column and row of data)

"[RODBC] ERROR: Could not SQLExecDirect 'insert into DataQuality(Descriptions,Date,Name,Ref)SELECT Descriptions,Date,Name,Ref FROMc(\\"Nothing to add\\"

, and seems to stop at the end of the first column.

Insertdata<-sqlSave( DBcon, df, "DataQuality",rownames=FALSE, append=TRUE)这将使用新数据帧更新SQL表。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM