order of columns in select * statement

Answered order of columns in select * statement

  • Thursday, January 17, 2013 10:16 PM
     
     

    I inherited a DB, app and some excel docs.

    The excel docs are not populating the columns in the same order they used to.

    The excel is populated via a query to an SQL view.

    The view was created with the columns in the right order and I don't want to go messing with excel stuff I am certain it is just a simple view dump.  I have not changed anything in the View script of the excel file.

    So what am I missing here?  How do I get the columns in order?

All Replies

  • Thursday, January 17, 2013 10:27 PM
     
     
    Post the view...
    • Edited by DIEGOCTN Thursday, January 17, 2013 10:27 PM
    •  
  • Thursday, January 17, 2013 10:28 PM
     
     

    you need to expressly select each column in the query.

    I don't know what columns will be returned nor the order for SELECT * FROM SomeTable

    However, I know what columns and the order when SELECT Id, NameLast, NameFirst, DateBirth FROM SomeTable

    Clarification:

    you need to expressly select each column in the query 'in the View script of the excel file.'

    • Edited by Rogge Thursday, January 17, 2013 10:29 PM
    •  
  • Thursday, January 17, 2013 11:22 PM
     
     Answered

    thanks for the replies.

    Found the issue.  It was Excel.  Her is what happened from what I can figure:

    Excel allows users to rearrange the columns and it someone remembers this order.  Client did this and i did not know.

    then for the rest of the session excel remembered the table order instead arranging to my view order.

    closed excel and reopened.....with a new column order (it was out of order before)..all is well.

    • Marked As Answer by CountryStyle Thursday, January 17, 2013 11:27 PM
    •