update newCustomerData set F_Usable=1 from newCustomerData as a where exists(select case len(b.F_Document) 
when '15' then stuff(b.F_Document,7,0,19) when '18' then substring(b.F_Document,1,6)+substring(b.F_Document,9,9) end as new18Document 
from TR_P_Customer b where b.new18Document=a.F_Document and b.F_SpecialFlag=1)
报new18Document列名无效

解决方案 »

  1.   

    update newCustomerData set F_Usable=1 
    from newCustomerData as a 
    where exists(select  1
                 from TR_P_Customer b 
                 where case len(b.F_Document) 
                            when '15' then stuff(b.F_Document,7,0,19) 
                            when '18' then substring(b.F_Document,1,6)+substring(b.F_Document,9,9) 
                        end=a.F_Document 
                     and b.F_SpecialFlag=1)