I need my IP list sorted. Problem is that i want them sorted after the value in the first part, then second part and so on.
MYTABLE
DATA
20.1.2.1
100.1.1.1
20.1.10.1
80.8.8.8
This code doesn’t order the IP correct
SELECT * FROM MYTABLE ORDER BY DATA
I was hoping to get something like this:
20.1.2.1
20.1.10.1
80.8.8.8
100.1.1.1
Can anyone help me ?
Although it wasn’t designed for IP addresses, you can use
PARSENAMEto divide a string into sections by splitting on the period.I see though that you have IP addresses with a colon instead of a period, so you would just need to replace all your colons with a period.
Thus, you could do:
You can throw this in Query Analyzer to confirm it works:
See the MSDN link for more information.