|
求教,如何从sql server数据库批量复制数据到本地ACCESS表。用for循环,速度太慢了
'''''''把数据复制到本地临时表
Dim rs As New ADODB.Recordset
Set cnn = New ADODB.Connection
Set mydb = CurrentProject.Connection
cnn.Open "rovider=SQLOLEDB;Data Source=192.168.0.1;UID=saWD=******;initial catalog=SHUJUKU"
If rs.State = 1 Then rs.Close
sql = "SELECT 字段1,字段2,字段3 FROM mssql表 GROUP BY 字段1,字段2,字段3"
rs.Open sql, cnn, 1, 1
If rs.EOF = False Then
''''用for循环,速度太慢了
For i = 1 To rs.RecordCount
DoCmd.RunSQL "insert into access表(字段1,字段2,字段3) VALUES( '" & rs!字段1 & "' ,'" & rs!字段2 & "' ,'" & rs!字段3 & "')"
rs.MoveNext
Next
End If
帮我改下代码,谢谢了
|
|