SELECT dotCode, GTIN, stockingStatus FROM tbl_IMPORT_DotStockingStatus WHERE eai_batchid = SELECT count(*), GTIN FROM tbl_IMPORT_DotStockingStatus WHERE eai_batchid = GROUP BY GTIN HAVING COUNT(*) > 1 SELECT * FROM tbl_IMPORT_Dotstockingstatus WHERE dotcode IN ( SELECT dotCode FROM tbl_DOT_StockingStatus ) AND GTIN NOT IN ( ) -- Remove Duplicates AND eai_batchId = SELECT * FROM tbl_DOT_StockingStatus WHERE dotcode NOT IN ( SELECT dotCode FROM tbl_IMPORT_DotStockingStatus WHERE eai_batchid = AND GTIN <> '00000000000000' ) SELECT * FROM tbl_IMPORT_Dotstockingstatus WHERE dotCode NOT IN (SELECT dotCode FROM tbl_DOT_StockingStatus) AND eai_batchId = AND GTIN <> '00000000000000' DELETE FROM tbl_DOT_StockingStatus WHERE dotCode = UPDATE tbl_DOT_StockingStatus SET stockingStatus = , GTIN = WHERE dotCode = INSERT INTO tbl_DOT_StockingStatus ( dotCode, GTIN, stockingStatus ) VALUES ( , , ) INSERT INTO tbl_DOT_StockingStatus ( DOTCode, GTIN, StockingStatus ) VALUES ( , , ) select s.fsl_tablecode, m.mfr_name companyName, count(*) skuCount from tbl_DOT_StockingStatus ds inner join tbl_PRD_Packaging pkg on pkg.scc14 = ds.gtin and pkg.linkType = 'SKU' inner join tbl_PRD_SKUS s on s.skuId = pkg.linkId and s.inactive = '0' and s.fsl_tablecode = 'MFR' inner join tblManufacturers m on m.mfr_id = s.ownerId group by s.ownerId, s.fsl_tablecode, m.mfr_name union select s.fsl_tablecode, b.broker_name companyName, count(*) skuCount from tbl_DOT_StockingStatus ds inner join tbl_PRD_Packaging pkg on pkg.scc14 = ds.gtin and pkg.linkType = 'SKU' inner join tbl_PRD_SKUS s on s.skuId = pkg.linkId and s.inactive = '0' and s.fsl_tablecode = 'BRO' inner join tblBrokers b on b.broker_id = s.ownerId group by s.ownerId, s.fsl_tablecode, b.broker_name order by s.fsl_tablecode DESC, companyName ASC select distinct ds.dotCode, ds.GTIN, ds.stockingStatus from tbl_IMPORT_Dotstockingstatus ds where ds.GTIN IN () and ds.GTIN != '00000000000000' order by ds.GTIN, ds.dotCode DELETE FROM tbl_DOT_StockingStatus WHERE GTIN = Records Added: #numRecAdded#
Records Updated: #numRecUpdated#
Records Removed: #numRecRemoved#

Duplicates Found: #numDupesFound#