I am new to stackoverflow, so forgive me if I break any forum rules. I currently use MS-Access as a front-end view to many ODBC-linked SQL server tables. My issue arises when I try to load a single column of data from a local table to an "updateable" table on the SQL server. Just pasting in 10k records takes upwards of 15 minutes and I'm looking for a solution on how to use a VB module to reduce this time. Using this link, How to increase performance for bulk INSERTs to ODBC linked tables in Access?, I was able to create a macro that runs at about the same speed as just pasting in, but I really need to increase the speed since it's just too slow.
My local table name is [tblTempSmartSSP] which contains one field (circuits)
My SQL Server ODBC-Linked table [dbo_REF_CIRCUIT_LIST_UPDATEABLE_RM] has a matching field name (circuits)
Sub PtqTest()
Dim cdb As DAO.Database, rst As DAO.Recordset
Dim t0 As Single, i As Long, valueList As String, separator As String
t0 = Timer
Set cdb = CurrentDb
Set rst = cdb.OpenRecordset("SELECT circuits FROM tblTempSmartSSP", dbOpenSnapshot)
i = 0
valueList = ""
separator = ""
Do Until rst.EOF
i = i + 1
valueList = valueList & separator & "(" & rst!circuits & ")"
If i = 1 Then
separator = ","
End If
If i = 1000 Then
SendInsert valueList
i = 0
valueList = ""
separator = ""
End If
rst.MoveNext
Loop
If i > 0 Then
SendInsert valueList
End If
rst.Close
Set rst = Nothing
Set cdb = Nothing
Debug.Print "Elapsed time " & Format(Timer - t0, "0.0") & " seconds."
End Sub
Sub SendInsert(valueList As String)
Dim cdb As DAO.Database, qdf As DAO.QueryDef
Set cdb = CurrentDb
Set qdf = cdb.CreateQueryDef("")
qdf.Connect = cdb.TableDefs("dbo_REF_CIRCUIT_LIST_UPDATEABLE_RM").Connect
qdf.ReturnsRecords = False
qdf.SQL = "INSERT INTO dbo_REF_CIRCUIT_LIST_UPDATEABLE_RM (Circuits) VALUES
" & valueList
qdf.Execute dbFailOnError
Set qdf = Nothing
Set cdb = Nothing
End Sub
Thank you in advance for any insight you provide!!
Ryan