Copying non duplicated data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bill robson
    New Member
    • Jun 2006
    • 2

    Copying non duplicated data

    Hi. I am stuck and was hoping for some help. I am using MSSQL and I need to extract data from one field (A) and append it to a second field (B) but only if the data in (A) does not allready exists in (B). The querry is run many times so the (B) field should only grow when something new is added to (A).
    EX.
    Field (A) = 123
    Field (B) = ""
    After first sql command
    Field (A) = 123
    Field (B) = 123

    Field (A) gets changed to
    123
    456
    After second sql command
    Filed (B) should be
    123
    456

    not
    123
    123
    456

    Any ideas are appreciated - Thanks
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I will not ask if field B is in the same row as field A because then you would not need this operation, so I assume that B is in another table.
    Since B is an exact copy of A, why don't you just replace the entire column B with column A with an UPDATE tableB... SET B=(SELECT A from tableA) ... ?
    Or is this not what you meant?

    Ronald :cool:

    Comment

    Working...