If you want to apply order by on column which contains data likes numbers, string..etc
Then here is the solution
1 2 3 4 5 |
SELECT * FROM TableName Order By CASE IsNumeric(ColumnName) WHEN 1 THEN Replicate('0',100-Len(ColumnName))+ColumnName ELSE ColumnName END |
Input:-
a
ba
ab
1
as
2
Output:-
1
2
a
ab
as
ba
🙂