Results 1 to 2 of 2

Thread: Multiple updates from a list

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Multiple updates from a list

    I have two lists, both comma delimited. the first contains record numbers within the table and the second field values in matching position and count. I want to update the table to reflect the changes in the list. So table will end up as shown below Table start & Table End.

    QUESTION: Can this be done with one SQL update statement, or must I loop over the list and do "X" SQL update statements?

    EXAMPLE:
    RecNums = "23,27,33,45,57,61"
    Values = "Blue,Red,Green,Blue,Red,White"

    TABLE
    RecNum Int Auto-Inc
    ColorVal VarChar(10)

    Table at start
    Rec# ColorVal
    -----|------------
    20 Yellow
    23 Yellow
    27 Yellow
    30 Yellow
    33 Yellow
    45 Yellow
    50 Yellow
    57 Yellow
    61 Yellow

    Table at end
    Rec# ColorVal
    -----|------------
    20 Yellow
    23 Blue
    27 Red
    30 Yellow
    33 Green
    45 Blue
    50 Yellow
    57 Red
    61 White

    Thanks!

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    First you need to get CSV list into a table, then you can update the original table with one statement by joining two tables.

Posting Permissions

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