SQL code to insert multiple rows in ms-access table

后端 未结 8 1682
北荒
北荒 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:09

    Is it possible to write the lines to a textfile? You can insert all the lines from that with ADO.

    db = "C:\Docs\ltd.mdb"
    
    Set cn = CreateObject("ADODB.Connection")
    
    cn.Open "Provider = Microsoft.Jet.OLEDB.4.0; " & _
       "Data Source =" & db
    
    sSQL = "INSERT INTO New (id,schedno) " _
    & "SELECT id,schedno FROM [new.txt] IN '' " _
    & "'text;HDR=Yes;FMT=Delimited;database=C:\Docs\';"
    
    cn.Execute sSQL
    

提交回复
热议问题