I have the same problem as described in the following link:
Sorting string column containing numbers in SQL?
I have a string column with numeric data that have white spaces both at beginning and at the end of column and I need to sort it.
The solution I found (in MySQL) is:
SELECT *
FROM data
ORDER BY left(st,LOCATE(st,' ')),
CAST(SUBSTRING(st,LOCATE(st, ' ')+1) AS SIGNED)
My question is if this solution is optimal and don't create huge load if I convert it to Mssql and run it on a table with more than 100.000 records.
Also please suggest me a conversion to Mssql because I am not very familiar with mssql.
Thanks
A SQL Server version of above-mentioned MySQL query might look like
Here is SQLFiddle demo
We never saw your sample data but if you just have numeric values with leading and/or trailing spaces in that column you can just do
Here is SQLFiddle demo