Ok been trying this for a couple of hours and few cups of coffee now getting dizzy. I am trying to dynamically map range of number to color hex. this is what I have so far. Me and case statements are not very close so I would really love to avoid that if at all possible.
[code]
create table #memoryscales (memoryscaleid int identity(1,1) , memorysizegb int not null, fromMem bigint, ToMem bigint , Memstatus varchar(50), StatusColor varchar(50)) ;
--Generate dynamic sample #memoryscales
;WITH Nums(memorysizegb) AS
(SELECT 1000 AS memorysizegb
UNION ALL
SELECT memorysizegb + 1000 FROM Nums where memorysizegb < 10000
)
insert into #memoryscales(memorysizegb)
select memorysizegb from Nums option(maxrecursion 100)
select * from #memoryscales
update tgt
set tgt.fromMem = tgt.memorysizegb - 999,
tgt.ToMem = tgt.memorysizegb
from #memoryscales tgt
update tgt
set tgt.Memstatus = case
when ToMem >= 10000 then 'Disaster'
else 'Shaka Laka Boom Boom'
end,
tgt.StatusColor = '#c73101'
from #memoryscales tgt
select * from #memoryscales
drop table #memoryscales