Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sorting

Author  Topic 

nuni2j
Starting Member

1 Post

Posted - 2008-07-21 : 00:22:59
Hi,

I have a columns that look like this in the table:

Task Name Outline Number
Work 1
In-house 1.1
External 1.2
Play 2
Drinking 2.1
Sport 2.3

I would like to sort my results by the Outline Number column which contains text fields. When you have so many tasks that you reach 10.1 then the sort is all wrong as the 10 comes directly after the 1.

Do you know how i could alter the Outline number field so i can pad the number with 0's for example 10.1.3 would be 0010.0001.0003 as this would ensure the correct order is always displayed.

Thanks,


Ananda

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-21 : 01:23:30
use fnParseString to extract each segment convert to integer and then sort it

fnParseString can be found here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -