UPDATE SEGMENTS
SET MARKASDELETED = 0
WHERE ISNULL(MARKASDELETED, 0) = 0

UPDATE POINTOFSALES
SET MARKASDELETED = 0
WHERE ISNULL(MARKASDELETED, 0) = 0

---------------------------------------------------------------

DELETE FROM AllotmentPOSXTab
WHERE POINTOFSALENUMBER IN (SELECT Number
                            FROM POINTOFSALES WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM ProductPOSXtab
WHERE POINTOFSALENUMBER IN (SELECT Number
                            FROM POINTOFSALES WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM POSPRODUCTTYPESXTAB
WHERE POS               IN (SELECT Number
                            FROM POINTOFSALES WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM YieldPointOfSalesXtab
WHERE POS               IN (SELECT Number
                            FROM POINTOFSALES WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)


---------------------------------------------------------------

DELETE FROM AllotmentSegXTab
WHERE SegmentNumber IN     (SELECT Number
                            FROM SEGMENTS WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM SegmentPointOfSaleXTab
WHERE SegmentNumber IN     (SELECT Number
                            FROM SEGMENTS WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)
                            
DELETE FROM ProductSegmentsXtab
WHERE SEGMENTNUMBER IN     (SELECT Number
                            FROM SEGMENTS WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM SEGMENTPRODUCTTYPESXTAB
WHERE SEGMENT IN           (SELECT Number
                            FROM SEGMENTS WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

DELETE FROM YieldSegmentXtab
WHERE SEGMENT IN           (SELECT Number
                            FROM SEGMENTS WITH (NOLOCK)
                            WHERE ISNULL(MARKASDELETED, 0) = 1)

---------------------------------------------------------------









