Sql Server query varchar data sort like int

Cast amount column into Numeric in ORDER BY clause while selecting:

SELECT * FROM MyTable
ORDER BY CAST(amount AS Numeric(10,0)) DESC

You can change the decimal point value according to your requirement to get more precise result:

SELECT * FROM MyTable
ORDER BY CAST(amount AS Numeric(10,2)) DESC
                                   ^

Result:

Id amount
3 10000
2 4568
1 2340

See this dbfiddle

Note: As @Ice suggested, this will fail if the amount field contains non numeric data like ab123 or xyz (obviously).


Try ABS():

SELECT * FROM MyTable ORDER BY ABS(MyCol) DESC;

SQL Fiddle