Sorting in Text and Number column vb.net NATURAL SORT

1.1k Views Asked by At

I have a text and numeric data in a column of excel. data is 1,2,3,A,B,C,D,10,11,12. I want to do sort these by SQL. and i want get data in below order 1,2,3,10,11,12,A,B,C,D.

So please can any one suggest how i do this. enter image description here

1

There are 1 best solutions below

0
On

Because SQL does not store items with any order, the order by clause can be used to return items in a specific order that is needed.

if you are already using an order_by clause, but are getting the wrong order, the order they are returned depends on the collation: http://msdn.microsoft.com/en-us/library/ms184391.aspx

You want your list sorted in ascending order, so you can use something like:

Select * from table ORDER BY order_by_expression
COLLATE SQL_Latin1_General_Cp437_BIN Asc

Hope this works!