>Anyway, I showed a generic solution for the field types which can not be easily constructed in SQL.
I think the generic solution will work for different field lengths (padr() would still be simpler), but the UNION will fail if you mix different field types.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)