Skip to content

Instantly share code, notes, and snippets.

@nikolasd
Last active August 23, 2023 10:53
Show Gist options
  • Save nikolasd/37af15e09b8bb53f83aab014bd1a116c to your computer and use it in GitHub Desktop.
Save nikolasd/37af15e09b8bb53f83aab014bd1a116c to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment