通过 Excel VBA 连接到 SQL Management Studio 后,我有以下代码(部分代码)从 SQL 表中提取数据。
With BalanceSheet
' Assign the Connection object.
.ActiveConnection = cnPubs
' Extract the required records.
.Open "select * from Analytics.dbo.BalSheetKeyLineItemsFinal"
Sheet1.Range("A13").CopyFromRecordset BalanceSheet
' Tidy up
.Close
End With
但是,表中的列名不显示。有没有办法在我的数据导出到 Excel 时包含列名?
谢谢!