alter table stor.T_INVENTORY_ELEMENTS_REMAINS alter column Remains uniqueidentifier;
go
update ier
set ier.Remains = null
from stor.T_INVENTORY_ELEMENTS_REMAINS  ier
join stor.T_INVENTORY_ELEMENTS ie on ie.InventoryElementsID = ier.InventoryElements
join STOR.T_INVENTORY_DOCUMENT id on id.InventoryDocumentID = ie.InventoryDocument
where id.Status = 2

update ier
set ier.Remains = null
from stor.T_SCANNED_INVENTORY_ELEMENTS ier
join stor.T_INVENTORY_ELEMENTS ie on ie.InventoryElementsID = ier.InventoryElements
join STOR.T_INVENTORY_DOCUMENT id on id.InventoryDocumentID = ie.InventoryDocument
where id.Status = 2