I created a views
on sql server
with the following column order:
Below are orders of the column when I select the view vwTable
Shift_id | Client_ip | Machine_Center
but when I'm going to select the views
using get external data
from the excel:
SELECT * FROM vwTable
The order of the column on EXCEL
is not the same, the output is:
Machine_Center | Client_ip | Shift_id
Screenshots:
from SSMS:
Select * from vwTable

from excel: get external data
Select * from vwTable

My problem is that the column order must be the same on views
Finally found the solution:
right click EXCEL column header
go to table => external table properties
Uncheck
"Preserve column sort/filter/layout"
Refresh excel
right click EXCEL column header
go to table => external table properties
check
"Preserve column sort/filter/layout"
Refresh excel
The order of the column in excel now were the same order in
views
Why not just name them in your select?
Select Shift_id, Client_ip, Machine_Center from vwTable
来源:https://stackoverflow.com/questions/28620640/excel-get-external-data-from-sql-server-excel-column-order-rearranged