/*
Naprawienie synchronizacji miedzy bazami (kodów) w scenariuszu
kilku firm pracujacych na wspolnych indeksach.
Desyncrhonizacja moze sie pojawic w przypadku zmian w kategoryzacji indeksu
po nadaniu numeru np zmiana indeksu detalowego na elektryczny gdzie grupa elektryczne ma wlasne kodowanie (numeracje)
*/
select x.itemid, x.itemCode ,y.itemCode,x.itemname,y.itemname from wms.item x inner join
BAZA1.wms.item y on x.itemID = y.itemID
where 'S01'+x.itemCode <> y.itemCode and x.status > -1
and len(x.itemcode) =10
/*Aktualizacja*/
BEGIN TRANSACTION test ;
update BAZA1.wms.item set itemcode = 'S01' + x.itemCode,fullTextCat = 0 --prefix jesli w drugiej instancji jest prefixowany
from BAZA2.wms.item x inner join
BAZA1.wms.item y on x.itemID = y.itemID
where 'S01'+x.itemCode <> y.itemCode and x.status > -1
and len(x.itemcode) =10
select x.itemid, x.itemCode ,y.itemCode,x.itemname,y.itemname from wms.item x inner join
BAZA1.wms.item y on x.itemID = y.itemID
where 'S01'+x.itemCode <> y.itemCode and x.status > -1
and len(x.itemcode) =10
--COMMIT TRANSACTION test
ROLLBACK transaction test