select objectiveId, territoryId from tbl_BCRM_Objectives with (nolock) where ownerId = and ownerType = and parentObjectiveId = select t.territoryId from tbl_FSPRO_MEmbers m with (nolock) inner join tbl_TER_Territories t with (nolock) on t.ownerId = m.ownerId and t.fsl_tablecode = m.fsl_tablecode and t.territoryId = m.primaryTerritoryId inner join tbl_TER_TerritoryLevels l with (nolock) on l.ownerId = t.ownerId and l.fsl_tablecode = t.fsl_tablecode and l.levelId = t.levelId and l.brokerLevel = 1 where m.ownerId = and m.fsl_tablecode = and m.staffMember = 1 and m.loginEnabled = 1 and m.fspro_userId = select distinct t.territoryId from tbl_FSPRO_MEmbers m with (nolock) inner join tbl_TER_TeamMembers tm with (nolock) on tm.ownerId = m.ownerId and tm.ownerType = m.fsl_tablecode and tm.teamMemberUserId = m.fspro_userId inner join tbl_TER_Territories t with (nolock) on t.ownerId = tm.ownerId and t.fsl_tablecode = tm.ownerType and t.territoryId = tm.territoryId inner join tbl_TER_TerritoryLevels l with (nolock) on l.ownerId = t.ownerId and l.fsl_tablecode = t.fsl_tablecode and l.levelId = t.levelId and l.brokerLevel = 1 where m.ownerId = and m.fsl_tablecode = and m.staffMember = 1 and m.loginEnabled = 1 and m.fspro_userId = select linkId from tbl_BCRM_ObjectiveStfLink where ownerId = and ownerType = and objectiveId = and territoryId = and fspro_userId = insert into tbl_BCRM_ObjectiveStfLink ( ownerId, ownerType, objectiveId, territoryId, fspro_userId, quota, quotaAchieved ) values ( , , , , , 0, 0 )