Last active
August 23, 2023 10:53
-
-
Save nikolasd/37af15e09b8bb53f83aab014bd1a116c to your computer and use it in GitHub Desktop.
Pylon SQL - Αλλαγή κωδικών πελατών και προμηθευτών σε αύξουσα αρίθμηση, διατηρώντας το πρόθεμα ΠΕΛΑ- και ΠΡΟΜ-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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