I'm not sure how to do this --
I've got a local table with fields as such that require updating.
select column_835 1,
column_836 = 6,
column_837 = 8,
column_838 = 1,
column_839 = 6,
column_840 = 3,
column_841 = 6,
column_842 = 8
from #esp
the updating statement reads like this --
update a
set column_835 = b.percent
from #esp a
join #local_data b on a.c_no = b.c and a.fyear = b.fyear
where b.color = 'blue'
what happens is i want to update row 'column_835' with the value in my local table where the color is blue.
the second query would update 'column_837'with the value for percent but that corresponds to green and so on. what i would love to do is to some how make one update statement instead of 8 or more. (if more colors get added we have to make more updates in the code).
How do I say update column_ from our local table with the
so for example
column_835 = percent (but only where b.color = blue)
column_837 = percent (but only where b.color = green)
column_842 = percent (but only where b.color = white)
and so on.
data comes from below -- I've also got a second table with data like this
select *
from T_VALUES v
where v.column_id = 728
the data from table 'values' for column_id 728 returns as follows
id keyword_no key_value
840 728 red
839 728 white
837 728 green
835 728 blue
841 728 yellow
838 728 black
842 728 white
836 728 purple