In Excel VBA macro coding I ran a query to pull data by joining three tables and placing the data in the columns under Sheet1.
The macro code to extract the data in Excel was:
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=SqlString)
where SqlString was set up as the following query:-
SELECT * FROM InvNum inum
LEFT JOIN _btlbInvoiceLines ilin
ON inum.AutoIndex = ilin.iInvoiceID
LEFT JOIN StkItem s
ON ilin.iStockCodeID = s.StockLink WHERE (InvNumber = 'IVQ0835' OR
InvNumber = 'IVQ0834')
I ran the SAME SQL query under Microsoft SQL Server Management Studio and noticed that the Excel query DROPPED THE LAST FIELD OF THE FIRST TABLE (InvNum) before appending the second and third table information in the remaining columns. The last field of the InvNum table should have gone into Excel column ED. Had some limit been exceeded?
All other fields were present in both queries.
This looks like either an SQL, or an Excel, bug.
PLEASE CAN YOU ASSIST IN FIXING THIS AS I AM RELYING ON THIS METHOD TO EXTRACT SQL DATA TO EXCEL?