SQL code to insert multiple rows in ms-access table

后端 未结 8 1699
北荒
北荒 2020-12-15 14:01

I\'m trying to speed up my code and the bottleneck seems to be the individual insert statements to a Jet MDB from outside Access via ODBC. I need to insert 100 rows at a tim

8条回答
  •  我在风中等你
    2020-12-15 14:31

    I found an elegant solution within R, (the software I'm working with). The RODBC package has a function sqlSave which allow to append and entire data.frame at once to a table. This works almost twice as fast as individual inserts within a transaction.

    library(RODBC)
    MDB <- odbcConnectAccess("database.mdb")
    sqlSave(channel = MDB, dat = sims, tablename = "tblSimulation", append = TRUE, rownames = FALSE)
    odbcClose(MDB)
    

提交回复
热议问题