January 15, 2009 at 11:44 pm
I need to fetch the record from table and order by integer wise.
like this.
1
2
3
10
11
2
23
24
25
1a
1b
1j
2a
2b
January 16, 2009 at 6:56 am
Please read the articles linked in my signature. Your question is incomplete as posted.
Just a shot in the dark, but if the column is a character data type and Order By column_name should work.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
January 20, 2009 at 5:50 am
I do not unsterstand the question
are you looking something like this?
declare @counter table
(
pk varchar(2)
)
insert into @counter
(pk)
values
('1'),
('2'),
('3'),
('10'),
('11'),
('2c'),
('2'),
('23'),
('24'),
('25'),
('1a'),
('1b'),
('1j'),
('2a'),
('2b')
select
pk
from
@counter
order by
convert(bigint ,
substring(pk,1,case
When PATINDEX('%[^0-9]%',pk)> 0 then
PATINDEX('%[^0-9]%',pk) -1
else
255
end
)
)
,SUBSTRING(pk,PATINDEX('%[^0-9]%',pk) ,255)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply