SQLTeam.com | Weblogs | Forums

Return result for comma seperated string field


#1

I am trying to Update a table with the description from another table

table 1 has two column result_id and Description
table two has 2 columns, codes which = result_id in table one and meaning which = Description in table one

the problem is that for each row in table 1 you may have multiple result_id separated by commas
example result_id = A124,C214,D214
I would like to lookup the result id from table 1 and return the meaning from table 2 to populate the description in table one. I can write an update statement that works only when there is a single result_id in table one. the problem is when i have multiple return_id per row


#2

Since there can be multiple Result_ID values in table 1, which Description would be used? Only the first? All of them (comma separated)?


#3

You need a fast CSV splitter for this. You can find one in the "RESOURCE" section at the bottom of the article found at the following URL.
http://www.sqlservercentral.com/articles/Tally+Table/72993/