T-Sql - Order By on Alphanumeric
i have a list of alphanumeric tokens, say '1a', '1b', '02', '03', '10', '11', etc... Now, what's the best way to do an order by on this list of tokens? I am getting '1a', '1b', '10', '11', '02', '03', but i need it to be '1a', '1b', '02', '03', '10', '11' UPDATE ok, i am doing this after the suggestion but it's not working. declare @tokens table(token varchar(20)); insert into @tokens select '1a' select '1b' select '02' select '10' select * from @tokens order by case when ISNUMERIC(token) = 1 then right('0000000000'+token+'0',10) else right('0000000000'+token,10) end I am getting the response