select opr.recordSource, opr.territoryId, ter.name territoryName, opr.companyName, opr.city, opr.state, opr.zipCode, left( opr.zipCode, 3 ) zip3d, opr.operatorId, dd.accountNumber from tbl_OPR_CLientOperators opr inner join tbl_TER_Territories ter on ter.territoryId = opr.territoryId inner join tbl_OPR_DistributionDetails dd on dd.operatorId = opr.operatorId and dd.ownerId = opr.ownerId and dd.ownerType = opr.fsltablecode and nullif( dd.accountNumber, '' ) is not null where opr.ownerId = and opr.fsltablecode = and opr.recordSource like 'Operator Import%' and ( right( opr.recordSource, 4 ) = '2014' or right( opr.recordSource, 4 ) = '2015' ) and nullif( opr.city, '' ) is not null select fseZipCode from tbl_IMPORT_Operators where tempCol = and company_city = and company_state = and eai_batchId = 483638 select distinct left( zipCode, 3 ) zip3d from tbl_USPS_CityStateDetails where cityStateName = and stateAbbr = select *, '' newTerritoryName, 0 newTerritoryId from qmd_subMarkets where goofy = 'Y' select ter.ownerId, ter.fsl_tablecode, ter.territoryId, ter.name territoryname from tbl_UT_ZipCodes_3d z3d inner join tbl_TER_ZipCodeLink zcl on zcl.zip3d_id = z3d.zip3d_id inner join tbl_TER_Territories ter on ter.territoryId = zcl.territoryId where z3d.zipCode_3d = and ter.ownerId = and ter.fsl_tablecode = select * from qmd_goofy where (( newTerritoryId <> territoryId ) or ( possible3d <> zip3d ))