Order characters numerically

It may be simple, but this SQL will order items numerically (1,2,3,10,20) instead of alpha (1,10,2,20,3).
Author: Nate Baxley
Published Date:9/27/2007
SELECT ItemID, ItemName, ItemNum,

CASE WHEN Len(ItemNum) = 0 THEN 'Z' ELSE SPACE(10- Len(ItemNum)) + ItemNum END OrderCol
FROM table
ORDER BY OrderCol

RSS Feed Log In to access RSS feeds.


Remember me on this computer

This Item Tagged as


Hover over an item above for
more information