select p.ownerId, p.ownerType, p.objectiveId, p.objName, p.territoryId, t.territoryPath subObjectiveTerritoryPath, '' commonPath from tbl_BCRM_Objectives p with (nolock) inner join tbl_BCRM_Objectives s with (nolock) on s.ownerId = p.ownerId and s.ownerType = p.ownerType and s.parentObjectiveId = p.objectiveId inner join tbl_TER_Territories t with (nolock) on t.ownerId = s.ownerId and t.fsl_tablecode = s.ownerType and t.territoryId = s.territoryId where p.objLevel = 'P' and nullif( p.territoryId, 0 ) is null and t.territoryPath is not null and p.ownerId > 0 and p.ownerType in ( 'MFR', 'BRO' ) -- and not ( p.ownerId = 387 and p.ownerType = 'BRO' ) order by objectiveId select territoryId, territoryPath from tbl_TER_Territories where ownerId = and fsl_tablecode= and territoryPath = update tbl_BCRM_Objectives set territoryId = where ownerId = and ownerType = and objectiveId = and nullif( territoryId, 0 ) is null
Updated #ownerType##ownerId# #objectiveId# #encodeForHTML( objName )# to #encodeforHTML( qmd_commonTerritory.territoryPath )#
Skipped #ownerType##ownerId# #objectiveId# #encodeForHTML( objName )#
Run time: #_elapsedTime# ms.