Pylon SQL - Αλλαγή κωδικών πελατών και προμηθευτών σε αύξουσα αρίθμηση, διατηρώντας το πρόθεμα ΠΕΛΑ- και ΠΡΟΜ-
UPDATE hecustomers
SET hecode = a.newcode
FROM (SELECT
heid,
concat(LEFT(hecode, 5), RIGHT(concat('00000000', ROW_NUMBER() OVER (ORDER BY hecode)), 8)) AS newcode
FROM hecustomers) AS a
INNER JOIN hecustomers
ON hecustomers.heid = a.heid
UPDATE hesuppliers
SET hecode = a.newcode
FROM (SELECT
heid,
concat(LEFT(hecode, 5), RIGHT(concat('00000000', ROW_NUMBER() OVER (ORDER BY hecode)), 8)) AS newcode
FROM hesuppliers) AS a
INNER JOIN hesuppliers
ON hesuppliers.heid = a.heid