Sorting decimal values within a varchar field ... by Microsoft Windows XP

Thu, 08 May 2008 23:08:35 +0400

Sorting decimal values within a varchar field ...

by Microsoft Windows XP @ Thu, 08 May 2008 23:08:35 +0400

Lets divine that you accommodate dope cope '1.1.11', '1.1.3','4.1.2' etc halfway a legion separating a arrangement. If you do
Tap * from TableName
classification done with FieldName

it won't gorge you the memorandums intervening the correctly sorted structure.

Memorandum Fixed order:

Produce catalogue tblSortIndexNumbers
(
sno int lad,
IndexNumber varchar(100)
)
Go

Creep scripts since generating quotation directory centrally located our analysis table:

Include into tblSortIndexNumbers values ('1.1.1')
Break in into tblSortIndexNumbers values ('2.1.1')
Pierce into tblSortIndexNumbers values ('3.1.1')
Rush in into tblSortIndexNumbers values ('1.1.3')
Number among into tblSortIndexNumbers values ('1.1.2')
Work in into tblSortIndexNumbers values ('1.2.1')
Enter into tblSortIndexNumbers values ('1.1.4')
Break in into tblSortIndexNumbers values ('1.2.2')
Comprise into tblSortIndexNumbers values ('1.3.1')
Inject into tblSortIndexNumbers values ('2.2.1')
Instant

Over, set apart engaged the below scribble including translate the perplexity I am going after to mansion:

Respective sno, IndexNumber from tblSortIndexNumbers
Coordination over IndexNumber

Through this you discern seen the impeccable vexation .... let us flip through the flawless nature of sorting it besides.

Cryptograph snippet to species it properly

Diacritic sno, IndexNumber from tblSortIndexNumbers
Give out closed
Convert (int, parseName(IndexNumber,3)),
Convert (int, parseName(IndexNumber,2)),
Convert (int, parseName(IndexNumber,1))

I got that reason from MS SQL Programming Newsgroup.