;with temp as (
select distinct LEFT(S,6)as C6
from test with (nolock)
)
,temp2 as
(select '1' as C,'0x0' as CB
union all
select '2' as C,'A2F' as CB
union all
select '3' as C,'8FB' as CB
union all
select '4' as C,'34F' as CB
union all
select '5' as C,'88A' as CB
union all
select '6' as C,'932' as CB
union all
select '7' as C,'86E' as CB
union all
select '8' as C,'E2F' as CB
union all
select '9' as C,'EEB' as CB
union all
select '0' as C,'23F' as CB
)
,temp3 as(
select C6,Tc1.CB+Tc2.CB+Tc3.CB+Tc4.CB+Tc5.CB+Tc6.CB as C6B
from temp
inner join temp2 as Tc1 on substring(temp.C6,1,1)=Tc1.C
inner join temp2 as Tc2 on substring(temp.C6,2,1)=Tc2.C
inner join temp2 as Tc3 on substring(temp.C6,3,1)=Tc3.C
inner join temp2 as Tc4 on substring(temp.C6,4,1)=Tc4.C
inner join temp2 as Tc5 on substring(temp.C6,5,1)=Tc5.C
inner join temp2 as Tc6 on substring(temp.C6,6,1)=Tc6.C
)
update test set S2=temp3.C6B+SUBSTRING(S,7,20) from test
inner join temp3 on temp3.C6=LEFT(test.S,6)
写了一个测试,本机笔记本执行了一下1000w条大概几分钟