I got a column called panel no
panel no
--------
1
10
1A
2A
6
...
I would like to have the order like
panel no
--------
1
1A
2A
6
10
I try "order by cast(panel no as signed)" and it works for mysql but not in SQL Server 2000.
what can I do?
I got a column called panel no
panel no
--------
1
10
1A
2A
6
...
I would like to have the order like
panel no
--------
1
1A
2A
6
10
I try "order by cast(panel no as signed)" and it works for mysql but not in SQL Server 2000.
what can I do?
You could adapt the solution of How to get the numeric part from a string using T-SQL? to your needs:
SELECT
*
FROM
TableA
WHERE
columnA = 'abc'
ORDER BY
CAST(LEFT([panel no], patindex('%[^0-9]%', [panel no] + '.') - 1) AS INT);
Please note that the column name panel no
contains a blank, so it's got to be quoted according the rules of T-SQL.
See this demo.
This solution is compatible with SQL Server 2000.