Problems with RODBC sqlSave

后端 未结 6 984
轻奢々
轻奢々 2021-02-14 17:39

I\'m having some difficulty inserting a data frame into a mySql database using RODBC. Below is the code I\'m using:

data <- data.frame(analysedDataID=c(1,2,3         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 18:11

    I was in the same situation some while back and my problem was rising from inserting data frame column numbers that did not match columns in the destination table. So this what I did. I did an SQL save with an append set to false (implying creation of a new table with a name different from the problematic table). Using the table_name and column_name of the INFORMATION_SCHEMA.COLUMNS of the working database I compared the two tables to determine the missing column.

    select * from INFORMATION_SCHEMA.COLUMNS
    where TABLE_NAME='table1'
    and COLUMN_NAME NOT IN
    (
    select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
    where TABLE_NAME='table2'
    )
    

    You can use table1 and table2 interchangeably. one would be the table the sqlsave is failing on while the other would be the one created on the fly

提交回复
热议问题