Results 1 to 10 of 10
  1. #1
    VAer's Avatar
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163

    Field Order

    Let us say, if a database table (not in Access, but in Sybase) has 3 fields (Field #1: ABC; Field #2: LMN; Field #3: XYZ).

    If I use Select * From Table_name and copy the whole table to a excel spreadsheet, it turns out that field order is exactly correct: Column A is ABC; Column B is LMN; Column C is XYZ.

    But to be safe, I prefer to use Select ABC, LMN, XYZ From Table_name, which should guaranteed the output result is in the order I expect (in case DBA modifies the field order in the database).

    Comparing the two ways to pull data from server, is there any big difference? I mean code efficiency difference. Will second method take much longer?



    In reality, the table has more than 40 fields, I need to pull 35 fields into excel spreadsheet. Is it a good idea to list all the 35 field names in Select statement? I don't mind to list them, since it is only one time deal, but my concern is more about code efficiency difference. Should I just copy the whole table from Sybase to Excel spredsheet first, then delete those columns from Excel spreadsheet? Or should I only copy those 35 fields into Excel sheet?


    Code efficiency is my main concern.

    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Since you're pulling fewer fields than exist, it should actually be more efficient to list them out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    VAer's Avatar
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163
    Quote Originally Posted by pbaldy View Post
    Since you're pulling fewer fields than exist, it should actually be more efficient to list them out.
    I need majority of fields. The reason I was asking is that I don't know how the system works.

    For example,
    1) I copy all 40 columns from Sheet 1 to Sheet 2, then delete 5 columns from Sheet 2.
    2) I copy one column at a time from Sheet 1 to Sheet 2, then I need to copy 35 times.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Pulling 35 fields is more efficient than pulling 40. I'd use the SQL to pull the 35. Not only is it more efficient, but you avoid the step of deleting the 5.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    VAer's Avatar
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163
    Quote Originally Posted by pbaldy View Post
    Pulling 35 fields is more efficient than pulling 40. I'd use the SQL to pull the 35. Not only is it more efficient, but you avoid the step of deleting the 5.
    Thanks much.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    VAer's Avatar
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163
    By the way, if a database table (not in Access, but in Sybase) has 3 fields (Field #1: ABC; Field #2: LMN; Field #3: XYZ).

    If I use Select * From Table_name and copy the whole table to a excel spreadsheet, it turns out that field order is exactly correct: Column A is ABC; Column B is LMN; Column C is XYZ.

    If I use
    Select XYZ, ABC From Table_name , will it guaranteed that column A is XYZ and column B is ABC?

    Does Select XYZ, ABC From Table_name already set up the column order in the output result by writing first column immediately following Select, then 2nd column, 3rd column, ....?

    Thanks.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    In my experience, the fields are always returned in the order they appear in the SELECT clause.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    VAer's Avatar
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163
    Quote Originally Posted by pbaldy View Post
    In my experience, the fields are always returned in the order they appear in the SELECT clause.
    Perfect. I am not familar with SQL.

    Thanks for all the information.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2016, 05:02 PM
  2. Replies: 23
    Last Post: 09-14-2015, 01:34 PM
  3. Replies: 9
    Last Post: 07-21-2015, 05:29 AM
  4. SQL Order By Date Field
    By ItsMe in forum Queries
    Replies: 3
    Last Post: 11-12-2013, 04:40 PM
  5. Setting a field in order for Report
    By cotri in forum Reports
    Replies: 2
    Last Post: 01-28-2010, 02:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums