SQL Server Performance

SELECT columns by column-index NOT by columnname!

Discussion in 'General Developer Questions' started by otto-mueller, Nov 20, 2005.

  1. otto-mueller New Member

    Hello all,

    how can I select one or more columns from a table by column-index and NOT by columnname?

    e.g.:


    SELECT tbl1.[1], tbl1.[2], tbl1.[3] FROM Orders AS tbl1

    and NOT like this:


    SELECT tbl1.OrderNo, tbl1.ProductNo, tbl1.Price FROM Orders AS tbl1

    Is that possible in MS-SQL 2000?

    Thanks a lot in advance

    kind regards

    Otto

  2. Luis Martin Moderator

    As far I know, no.


    Luis Martin
    Moderator
    SQL-Server-Performance.com

    One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important
    Bertrand Russell


    All postings are provided “AS IS” with no warranties for accuracy.



  3. otto-mueller New Member

    thanks for the quick answer.

    what a pity!

    Greeting
    Otto
  4. Adriaan New Member

    It's not really "a pity". It really isn't. It's more a matter of perspective.

    Are you by any chance a programmer new to SQL Server? You will find that with databases, (1) it is a good thing to just know the data structure before working on any procedure or query, and (2) it is good to know about set-based operations - newby T-SQL developers often have to unlearn the loop-through-recordset approach they're familiar with, and start thinking in terms of T-SQL batch operations.

    Also, if you're just coming into the realm of bearing responsibility for actual data, not just the interface, you will find that you probably have taken data integrity for granted, and you will start to appreciate that the easy way out is usually not the proper solution.

    Have fun!
  5. ranjitjain New Member

    Select query with column index is not possible.
    But in select query order by with selected column index is possible.
    Like
    Select col1,col2 from urtable order by 1

    so here 1 is col1.
  6. Madhivanan Moderator

Share This Page