【发布时间】:2016-05-28 12:48:42
【问题描述】:
SELECT
f.feature_id,
f.site_code,
f.plot_number,
'ID Error - 7th and 8th characters of ID do not match the Island of the selected Structure, expected value: ' + f.ward_code as message_text,
'Y' as IsError
FROM feature f
inner join feature_type ft on f.feature_type_code = ft.feature_type_code AND ft.feature_group_code IN ('FC')
WHERE f.ward_code <> RIGHT(LEFT(f.feature_id, 8),2)
union
SELECT
f.feature_id,
f.site_code,
f.plot_number,
'ID Error - Engineering District do not match the Region of the selected Structure, expected value: '+ laa.region as message_text,
'Y' as IsError
FROM feature f
inner join feature_type ft on f.feature_type_code = ft.feature_type_code AND ft.feature_group_code IN ('FC')
inner join loc_ase.loc_db.dbo.loc_admin_area laa on f.contract_area_code = laa.contract_area_code
WHERE f.[area_code] collate SQL_Latin1_General_CP1_CI_AS <> laa.[region] collate SQL_Latin1_General_CP1_CI_AS
【问题讨论】: