update tbl_GTM_Campaigns set campaignName = , startDate = , endDate = , campaignEnabled = , campaignDescription = , targetPartnerType = , leadType = , campaignManagerUserId = , salesManagerUserId = , businessOwnerType = , businessOwnerId = , campaignType = , campaignGroupId = , businessOwnerRefNum = , territoryId = , targetListId = , updateDate = , updatedBy = where ownerId = and ownerType = and campaignId = and updateDate = and updateDate is null insert into tbl_GTM_Campaigns( ownerId, ownerType, campaignName, startDate, endDate, campaignEnabled, campaignDescription, campaignType, campaignGroupId, campaignManagerUserId, salesManagerUserId, targetPartnerType, targetListId, leadType, businessOwnerType, businessOwnerId, businessOwnerRefNum, territoryId, createdBy, createDate, updatedBy, updateDate ) values ( , , , , , , , , , , , , , , , , , , , , , ) insert into tbl_EML_Campaign( ownerId, fsl_tablecode, campaignType, [name], emailFrom, emailFromDisplay, emailSubject, scheduled, useInternalContact, includeUnsubscribe, statusCd, emailManagerVersion, emailEditorType, creator_typ, creator_member_id, createDate, updateUserId, lastUpdatedDate, gtmCampaignId , targetListId ) values ( , , 'CRM', , , , , 'N', 0, 0, 'PEN', '2.0', 'BEE', 'FSP', , , , , , ) declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @campaignId int = ; update tbl_GTM_Campaigns set emailCampaignId = where ownerId = @ownerId and ownerType = @ownerType and campaignId = @campaignId declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @emailCampaignId int = ; update tbl_EML_Campaign set name = where ownerId = @ownerId and fsl_tablecode = @ownerType and campaignId = @emailCampaignId declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @gtmCampaignId int = ; update tbl_EML_Campaign set targetListId = where ownerId = @ownerId and fsl_tablecode = @ownerType and gtmCampaignId = @gtmCampaignId and statusCd = delete from tbl_ORG_AttributeLinks where mstr_attrTypeId = and mstr_attrId = and child_attrTypeId = insert into tbl_ORG_AttributeLinks ( mstr_attrTypeId, mstr_attrId, child_attrTypeId, child_attrId ) values ( , , , ) delete from tbl_ORG_AttributeLinks where mstr_attrTypeId = and mstr_attrId = and ( child_attrTypeId = or child_attrTypeId = or child_attrTypeId = ) insert into tbl_ORG_AttributeLinks ( mstr_attrTypeId, mstr_attrId, child_attrTypeId, child_attrId ) values ( , , , )