那第二个问题呢? 就是第二条数据没处理 麻烦下了加上Isnull 数据都没变化,没处理到更新 UPDATE house SET house.HouseType = a.HouseType, house.DataType = a.DataType, house.ProjectName = a.ProjectName , house.Area = a.Area FROM ( select h.Phone, ISNULL(ht.HouseType,case when charindex(ht.HouseType, h.HouseType)=0 then h.HouseType+','+ht.HouseType else h.HouseType end) HouseType, ISNULL(ht.DataType, case when charindex(ht.DataType, h.DataType)=0 then h.DataType+','+ht.DataType else h.DataType end) DataType, ISNULL(ht.ProjectName,case when charindex(ht.ProjectName , h.ProjectName )=0 then h.ProjectName +','+ht.ProjectName else h.ProjectName end) ProjectName, ISNULL(ht.Area, case when charindex(ht.Area, h.Area)=0 then h.Area+','+ht.Area else h.Area end) Area from House h inner join HouseTemp ht on h.Phone = ht.Phone ) a INNER JOIN house b ON a.Phone = b.Phone
这个是重点
UPDATE house
SET house.HouseType = a.HouseType,
house.DataType = a.DataType,
house.ProjectName = a.ProjectName ,
house.Area = a.Area
FROM (
select h.Phone,
ISNULL(ht.HouseType,case when charindex(ht.HouseType, h.HouseType)=0 then h.HouseType+','+ht.HouseType
else h.HouseType end) HouseType,
ISNULL(ht.DataType, case when charindex(ht.DataType, h.DataType)=0 then h.DataType+','+ht.DataType
else h.DataType end) DataType,
ISNULL(ht.ProjectName,case when charindex(ht.ProjectName , h.ProjectName )=0 then h.ProjectName +','+ht.ProjectName
else h.ProjectName end) ProjectName,
ISNULL(ht.Area, case when charindex(ht.Area, h.Area)=0 then h.Area+','+ht.Area
else h.Area end) Area
from House h
inner join HouseTemp ht on h.Phone = ht.Phone
) a INNER JOIN
house b ON a.Phone = b.Phone