select distinct s.ownerId, s.fsl_tablecode, s.skuId, s.gs1_syncDate, s.gs1_sentTOFse
from tbl_PRD_SKus s with (nolock)
inner join tblManufacturers m with (nolock)
on m.mfr_id = s.ownerId
inner join tbl_GS1_itemHierarchy ih with (nolock)
on s.gs1_item in ( ih.publishedGTIN, ih.parentGTIN, ih.childGTIN )
and ih.GLN = m.gs1_gln
inner join tbl_1SYNC_Documents d with (nolock)
on d.publishedGTIN = ih.publishedGTIN
inner join tbl_1SYNC_Transactions t with (nolock)
on t.txId = d.txId
and t.datarecipientGLN = '1100001017829'
where s.gs1_sentTOFse = '?'
and s.fsl_tablecode = 'MFR'
and s.gs1_syncDate is not null
order by ownerId
update tbl_PRD_SKus
set gs1_sentToFse = 'Y'
where ownerId =
and fsl_tablecode =
and skuId =