Hello, SQL2008R2
I have a column that is VARCHAR(10) with a reference number. Unfortunately there are some reference numbers with a character. I want to be able to index the reference number so that 100021999, 100022000 does not have 100022 between it. The reference numbers with the character can be at the start or the finish but I would like to sort the rest like an integer.
Current order:[tt]
100000
100000001
100021999
100022
100022000
100022642
100023
100024
99999
D67332[/tt]
The order I would like is:[tt]
99999
100000
100022
100023
100024
100000001
100021999
100022000
100022642
D67332[/tt]
If I did not have the character values I would cast as integer.
Thanks for suggestions,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
I have a column that is VARCHAR(10) with a reference number. Unfortunately there are some reference numbers with a character. I want to be able to index the reference number so that 100021999, 100022000 does not have 100022 between it. The reference numbers with the character can be at the start or the finish but I would like to sort the rest like an integer.
Current order:[tt]
100000
100000001
100021999
100022
100022000
100022642
100023
100024
99999
D67332[/tt]
The order I would like is:[tt]
99999
100000
100022
100023
100024
100000001
100021999
100022000
100022642
D67332[/tt]
If I did not have the character values I would cast as integer.
Thanks for suggestions,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!