|
原帖:http://club.excelhome.net/thread-1137145-1-1.html
Sub 宏1()
Dim cnn As Object
Dim SQL As String
Set cnn = CreateObject("ADODB.Connection")
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\data of shipping.accdb"
SQL = "select b.Acquired_Price,b.Builder,b.Builder_CoD from [Excel 12.0;Database=" & ThisWorkbook.FullName _
& ";].[" & ActiveSheet.Name & "$d1:d" & Range("d" & Rows.Count).End(xlUp).Row _
& "] a left join (select Acquired_Price,Builder,Builder_CoD,first(Builder_ID) as Builder_ID from Sheet1 group by Acquired_Price,Builder,Builder_CoD) b on a.Builder_ID=b.Builder_ID"
Range("A2").CopyFromRecordset cnn.Execute(SQL)
cnn.Close
Set cnn = Nothing
End Sub
问题点:在使用该代码的时候。access数据量比较小的时候测试可以用,但是我用另一个access(20万条数据)就不能正常工作了,只能查询到部分信息,也没有报错。请大神解答下。怎么优化。
|
|