Update table1 set BD_COL=ltrim(rtrim(MAT_DRG) from table1 inner join table2 on
(([name] like '24_%' and Substring([name],4,len([name])=ltrim(rtrim(MAT_DRG)) and isnull(MAT_DRG,'') and itemtype='STD')
or
([name] like '24/%' and Substring([name],4,len([name])=ltrim(rtrim(MAT_DRG)) and isnull(MAT_DRG,'') and itemtype='STD')
or
([name] like '24_%' and Substring([name],7,16)=ltrim(rtrim(MAT_DRG)) and itemtype='STD')
or ltrim(rtrim(MAT_DRG))=[name])
)
答案 0 :(得分:0)
像Substring([name],4,len([name])=ltrim(rtrim(MAT_DRG))
这样的表达会损害性能,甚至会在名称列上创建索引。考虑将计算列创建为SubString(name, 4, len(name))
并在此新列上创建索引。
对其他表达式和列执行相同的操作。