select spl.opportunityId, spl.subjectId, spl.fseProdId, spl.fseProdComments, spl.stageId, spl.fseProdIdDt from tbl_SPL_Opportunities spl inner join tbl_PRD_Products p on p.prodId = spl.fseProdId and p.ownerId = spl.ownerId and p.fsl_tablecode = spl.ownerType and p.inactive = '0' where spl.ownerId= and spl.ownertype = and spl.fseProdId is not null and subjectType = 'GTM' update tbl_SPL_Opportunities set subjectId = , subjectType = 'PRD', saveSubjectId = where opportunityId = and subjectId = and subjectType = 'GTM' insert into tbl_SPL_Opportunity_stageChanges ( opportunityId, previousStageId, newStageId, changeDateTime, fspro_userid, event, message ) values( , , , , 151554, 'changed', )