Excel Get External data from Sql Server: Excel Column order rearranged

☆樱花仙子☆ 提交于 2019-12-07 19:11:00

问题


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


回答1:


Finally found the solution:

  1. right click EXCEL column header

    • go to table => external table properties

    • Uncheck "Preserve column sort/filter/layout"

    • Refresh excel

  2. 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




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!