update a set a.AreaCode=(SUBSTRING(h.NAME,1,1)+'0'+SUBSTRING(h.NAME,2,1)+'0J') from T_BD_SmokeSensor a left join T_BD_Area b on a.AreaCode=b.AreaCode--系统区域表 left join [FuAnDB].[dbo].[ent_enterprise] g on a.ENTERPRISE_ID=g.ID--单位基础表 left join [FuAnDB].[dbo].[ent_building] h on a.BUILDING_ID=h.ID--建筑基础表 left join [FuAnDB].[dbo].[ent_keypart] i on a.KEYPART_ID=i.ID--消防重点部位基础表 where g.NAME like '%[A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z]%' and h.NAME like '%[A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z]%' and i.NAME like '%夹%' and LEFT(h.NAME,3) like '%[栋|-]%' and a.AreaCode is null