RODBC sqlSave table creation problems

前端 未结 6 2027

I\'m having trouble creating a table using RODBC\'s sqlSave (or, more accurately, writing data to the created table).

This is different than the existing sqlSave qu

6条回答
  •  有刺的猬
    2020-12-15 11:55

    After re-reading the RODBC vingette and here's the simple solution that worked:

    sqlDrop(db, "df", errors = FALSE)
    sqlSave(db, df)
    

    Done.

    After experimenting with this a lot more for several days, it seems that the problems stemmed from the use of the additional options, particularlly table = or, equivalently, tablename =. Those should be valid options but somehow they manage to cause problems with my particular version of RStudio ((Windows, 64 bit, desktop version, current build), R (Windows, 64 bit, v3), and/or MS SQL Server 2008.

    sqlSave(db, df) will also work without sqlDrop(db, "df") if the table has never existed, but as a best practice I'm writing try(sqlDrop(db, "df", errors = FALSE), silent = TRUE) before all sqlSave statements in my code.

提交回复
热议问题