I need to run an update on one numeric field in the database so that all entries have the same number of digits. Currently, while most have 10 digits, with preceding zeros to fill the extra spaces, about 1/3 have no preceding spaces, which causes them to sort incorrectly. How can I add zeros before the number until the number has the same number of digits as the majority have?
I am assuming that it would be something like:
UPDATE Table
SET field = '00000' & field
WHERE field = '--'
using the underscore wildcard for the existing digits. I would then have to run the update once for every length of number (ie, once for those entries that have 3 characters, then those that have 2, then those that have 1, etc.). This would not be an annoyance, because I only have to do this once to make some new imported data align with the existing structure.
Am I on the right track, or is there a simpler way?
Cheryl dc Kern
I am assuming that it would be something like:
UPDATE Table
SET field = '00000' & field
WHERE field = '--'
using the underscore wildcard for the existing digits. I would then have to run the update once for every length of number (ie, once for those entries that have 3 characters, then those that have 2, then those that have 1, etc.). This would not be an annoyance, because I only have to do this once to make some new imported data align with the existing structure.
Am I on the right track, or is there a simpler way?
Cheryl dc Kern