update stage set stage.custom_18 = 'SKU NOT FOUND', stage.custom_19 = stage.sku_MfrId from tbl_IMPORT_ProductData stage where stage.eai_batchid = and nullif(sku_skuid,'') is null and nullif(stage.sku_MfrId,'') is not null update stage set stage.sku_MfrId = null, stage.custom_1 = null from tbl_IMPORT_ProductData stage where stage.eai_batchid = and stage.custom_18 = 'SKU NOT FOUND' select i.eai_linenumber, i.mfr_mfrName, i.sku_packSizeDesc, i.sku_sku, i.sku_skudesc, i.sku_skuId, i.sku_MfrId, custom_1, custom_2, custom_3, custom_4 from tbl_IMPORT_ProductData i with (nolock) where i.eai_batchid = and i.sku_MfrId IS NULL order by i.sku_sku, i.mfr_mfrName declare @productCode as varchar(150) declare @mfrName as varchar(150) select @productCode = #attributes.datasource#.dbo.RemoveChars('#_mfrSku_Clean#','32,45,160,1') select @mfrName = #attributes.datasource#.dbo.RemoveChars('%#_mfrName_Clean#%','32,45,39,160,1') select s.skuid, m.mfr_id, m.mfr_name, s.sku, s.skudesc, s.packsizeDesc from tbl_PRD_Skus s with (nolock) inner join -- this is faster (select mfr_Name, mfr_id from tblManufacturers m where mfr_Name NOT LIKE '%Delete%') as m on m.mfr_id = s.mfrid where s.fsl_TableCode = 'MFR' and #attributes.datasource#.dbo.RemoveChars(s.sku,'32,45,160,1') = @productCode and #attributes.datasource#.dbo.RemoveChars(m.mfr_name,'32,45,39,160,1') like @mfrName declare @productCode as varchar(150) declare @mfrName as varchar(150) select @productCode = #attributes.datasource#.dbo.RemoveChars('#_mfrSku_Clean#','32,45,160,1') select @mfrName = #attributes.datasource#.dbo.RemoveChars('%#_mfrName_Clean#%','32,45,39,160,1') select s.skuid, m.mfr_id, m.mfr_name, s.sku, s.skudesc, s.packsizeDesc from tbl_PRD_Skus s with (nolock) inner join -- this is faster (select mfr_Name, mfr_id, mfrAbbrev_name from tblManufacturers m where mfr_Name NOT LIKE '%Delete%') as m on m.mfr_id = s.mfrid where s.fsl_TableCode = 'MFR' and #attributes.datasource#.dbo.RemoveChars(s.sku,'32,45,160,1') = @productCode and #attributes.datasource#.dbo.RemoveChars(m.mfr_name,'32,45,39,160,1') like @mfrName declare @productCode as varchar(150) declare @mfrName as varchar(150) select @productCode = #attributes.datasource#.dbo.RemoveChars('#_mfrSku_Clean#','1,32,45,160') select @mfrName = #attributes.datasource#.dbo.RemoveChars('%#_mfrName_Clean#%','32,45,39,160,1') select s.skuid, m.mfr_id, m.mfr_name, s.sku, s.skudesc, s.packsizeDesc from tbl_PRD_Skus s with (nolock) inner join -- this is faster (select mfr_Name, mfr_id from tblManufacturers m where mfr_Name NOT LIKE '%Delete%') as m on m.mfr_id = s.mfrid inner join tbl_PRD_Packaging pk with (nolock) on pk.linkid = s.skuid and pk.linkType = 'SKU' where s.fsl_TableCode = 'MFR' and #attributes.datasource#.dbo.RemoveChars(pk.scc14,'32,45,160,1') = @productCode and #attributes.datasource#.dbo.RemoveChars(m.mfr_name,'32,45,39,160,1') like @mfrName declare @productCode as varchar(150) declare @mfrName as varchar(150) select @productCode = #attributes.datasource#.dbo.RemoveChars('#_mfrSku_Clean#','32,45,160,1') select @mfrName = #attributes.datasource#.dbo.RemoveChars('%#_mfrName_Clean#%','32,45,39,160,1') select s.skuid, m.mfr_id, m.mfr_name, s.sku, s.skudesc, s.packsizeDesc from tbl_PRD_Skus s with (nolock) inner join -- this is faster (select mfr_Name, mfr_id, mfrAbbrev_Name from tblManufacturers m where mfr_Name NOT LIKE '%Delete%') as m on m.mfr_id = s.mfrid inner join tbl_PRD_Packaging pk with (nolock) on pk.linkid = s.skuid and pk.linkType = 'SKU' where s.fsl_TableCode = 'MFR' and #attributes.datasource#.dbo.RemoveChars(pk.scc14,'32,45,160,1') = @productCode and #attributes.datasource#.dbo.RemoveChars(m.mfr_name,'32,45,39,160,1') like @mfrName update tbl_IMPORT_ProductData set sku_skuId = , custom_1 = , custom_2 = , custom_3 = , custom_4 = , sku_MfrId = where eai_batchid = and eai_linenumber =