Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Location
    Treviso (Italy)
    Posts
    17

    Unanswered: Field by Position

    Hi, Nobody have idea to get a field in "select" statement by its position (without name then)?

    My scope was to duplicate a row into a table with identity column getting all row except the identity one, that i want to provided by constant expression.

    Bye and thanks...



  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You will need to use dynamic SQL (constructing your SQL Statements at runtime) by referencing the database Schema or the sysobjects and syscolumns tables.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Uhmmm...why do you need to do this...?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Jun 2004
    Location
    Treviso (Italy)
    Posts
    17
    Often I have duplicate row in table with a lot of columns ... and i wanted a statement to avoid to call each time columns by name ...

    The real scope was to find a statement to say : "Get all the columns except primary key ... that I provide by constant expression ....."

    Maybe the unique solution is to prepare a program to write statement how i need

    Thanks

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    why not just write the query with all the column names except the primary key?

    that would've taken no more than a minute or two, a lot faster than writing a query to go against the system tables, and a lot faster than writing a program to do that
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •