select distinct ssc.ownerId, ssc.ownerType, ssc.contentRule, ssc.linkType, ssc.linkId from tbl_PRD_SyndicationSets ss inner join tbl_PRD_SyndicationSetContents ssc on ssc.syndicationSetId = ss.syndicationSetId and ssc.ownerId = ss.ownerId and ssc.ownerType = ss.ownerType and ssc.linkType = 'SKU' and ssc.contentRule = 'INCLUDE' and ssc.ownerType = 'MFR' and exists ( select * from tbl_PRD_Skus s where s.ownerId = ssc.ownerId and s.fsl_tablecode = ssc.ownerType and s.skuId = ssc.linkId ) where ss.linkType = 'CHO' and ss.linkId in ( select cho_id from tbl_CHO_Operators where cho_1fsSchoolsMember = 'Y' ) order by ssc.ownerId select * from tbl_PRD_SyndicationSets ss where syndicationSetId in ( select syndicationSetId from tbl_PRD_Subscriptions where subscriberType = '1FSSCH' and ownerId = and ownerType = 'MFR') and ownerId = and ownerType = 'MFR' delete from tbl_PRD_SyndicationSets where syndicationSetId in ( ) and ownerId = and ownerType = 'MFR' delete from tbl_PRD_SyndicationSetContents where syndicationSetId in ( ) and ownerId = and ownerType = 'MFR' delete from tbl_PRD_Subscriptions where syndicationSetId in ( ) and ownerId = and ownerType = 'MFR'

Deleting

update tbl_PRD_SyndicationSets set syndicationSetName = '1FS Schools' where syndicationSetId = and ownerId = and ownerType = 'MFR'

Updating

select * from tbl_PRD_SyndicationSets where ownerId = and ownerType = 'MFR' and syndicationSetName = '1FS Schools' insert into tbl_PRD_SyndicationSets ( ownerId, ownerType, syndicationSetName, systemSet ) values( , 'MFR', '1FS Schools', 'N' ) select * from tbl_PRD_SyndicationSets ss where syndicationSetId = and ownerId = and ownerType = 'MFR' insert into tbl_PRD_Subscriptions( ownerId, ownerType, syndicationSetId, subscriberType, subscriberId ) values ( , 'MFR', , '1FSSCH', 0 )

Creating

select * from tbl_PRD_SyndicationSetContents where syndicationSetId = and ownerId = and ownerType = 'MFR' and linkType ='OPT' and contentRule = 'INCLUDE' and linkId = 0 and linkConfig = 'SCHOOLPRODUCT=Y' insert into tbl_PRD_SyndicationSetContents ( ownerId, ownerType, syndicationSetId, contentRule, linkId, linkType, linkConfig ) values ( , 'MFR', , 'INCLUDE', 0, 'OPT', 'SCHOOLPRODUCT=Y' )
update tbl_PRD_Skus set schoolProduct = 'Y' where skuId = and ownerId= and fsl_tablecode = 'MFR' delete from tbl_PRD_SyndicationSetContents where ownerId = and ownerType = 'MFR' and syndicationSEtId = and contentRule = and linkId = and linkType =