Results 1 to 4 of 4

Thread: Sql Update

  1. #1
    Join Date
    Jun 2004
    Posts
    57

    Unanswered: Sql Update

    hi,

    i have 2 table a and b. i want to write a sql statement to update a from b which have same column name.
    for example a have column {a1, a2, a3, a4}
    and b have column {b1, a2, a3, b4}

    I need to update a.a2 = b.a2 and a.a3 = b.a3. without hardcode the column name.


    anybody have any idea?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    It sounds to me like you are trying to create dynamic SQL, but I don't understand what you are asking for well enough to help you write it. Can you explain in more detail?

    -PatP

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    ...and this could be dangerous as a mindless dynamic SQL statements. For example, two table could both contain columns labeled "Type", but they could hold very different information.
    If it's not practically useful, then it's practically useless.

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

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Sounds like a self join to INFORMATION_SCHEMA.Columns ON COLUMN_NAME...

    But what about the keys?

    Got any?

    That'll be harder to add...

    But it doesn't make any sense....what are you trying to do?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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