select 'CDR' partnerType, cdr_recordId partnerId, cdr_territoryId territoryId from tbl_CDR_Distributors with (nolock) where ownerId = and fsl_tablecode = and cdr_recordId = select 'OPR' partnerType, operatorId partnerId, territoryId territoryId from tbl_OPR_ClientOperators with (nolock) where ownerId = and fsltablecode = and operatorId = select fspro_userId as contactId from tbl_FSPro_Members with (nolock) where ownerId = and fsl_tablecode = and fspro_userId = update tbl_WRK_FormSubmissions set leadStatus = , leadPartnerId = , leadPartnerType = , leadTerritoryId = , leadContactId = , leadCompanyAction = , leadContactAction = , leadDispositionDate = , leadDispositionUserId = where ownerId = and ownerType = and submissionId = and coalesce( leadStatus, '?' ) = ---> select objName, objDescription from tbl_BCRM_Objectives with (nolock) where ownerId = and ownerType = and objectiveId = You have been assigned to the following Objective and have a quota as indicated above. [Click Here] to view this Objective in the Portal. The Objective goal is as follows: #chr(13)##chr(10)##chr(13)##chr(10)# #qmd_objective.objDescription# #chr(13)##chr(10)##chr(13)##chr(10)# #_emailSignature# select m.fspro_userId, m.ownerId, m.fsl_tablecode, m.firstName, m.lastName, m.email from tbl_BCRM_ObjectiveTrgLink otl with (nolock) inner join tbl_BCRM_Objectives o with (nolock) on o.ownerId = otl.ownerId and o.ownerType = otl.ownerType and o.objectiveId = otl.objectiveId inner join tbl_Fspro_members m with (nolock) on m.ownerId > 0 and m.fsl_tablecode in ( 'MFR', 'BRO' ) and m.fspro_userId = otl.origRepAssignment where otl.ownerId = and otl.ownerType = and otl.targetType = and otl.targetId = and ( o.objectiveId = or o.parentObjectiveId = ) declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @objectiveId int = ; declare @partnerId int = ; declare @partnerType varchar(3) = ; select i.interactionId, o.objectiveId from tbl_CRM_Interactions i with (nolock) inner join tbl_CRM_InteractionParticipants ip with (nolock) on ip.ownerId = i.ownerId and ip.ownerType = i.ownerType and ip.interactionId = i.interactionId inner join tbl_BCRM_ObjectiveTrgLink otl with (nolock) on otl.linkId = ip.participantId and otl.ownerId = i.ownerId and otl.ownerType = i.ownerType inner join tbl_BCRM_Objectives o with (nolock) on o.ownerId = i.ownerId and o.ownerType = i.ownerType and o.objectiveId = otl.objectiveId where i.ownerId = @ownerId and i.ownerType = @ownerType and i.partnerId = @partnerId and i.partnerType = @partnerType and ( o.objectiveId = @objectiveId or o.parentObjectiveId = @objectiveId ) select f.formId, f.formName from tbl_WRK_Forms f with (nolock) inner join tbl_WRK_FormSubmissions s with (nolock) on s.ownerId= f.ownerId and s.ownerType= f.ownerType and s.formId = f.formId where s.ownerId = and s.ownerType = and s.submissionId = select campaignId, campaignName, objectiveId from tbl_GTM_Campaigns with (nolock) where ownerId = and ownerType = and campaignId =