I have the similar problem. I have used this query below.
To use this query u must know the ID (string) maximum length and I have adjusted the format in this query to use Mark-Number+Alphabet (example R-1,R-1A, R-11, R-11A, R-1AA,R-1B)
Query:
select
b.CardNo, b.separatorIndex
,b.Mark, b.Mark_length
,case b.isNumericMark1 + b.isNumericMark2 + b.isNumericMark3
when 1 then cast (b.Mark1 as int)
when 2 then cast (b.Mark1 + b.Mark2 as int)
when 3 then cast (b.Mark1 + b.Mark2 + b.Mark3 as int)
end as Mark1
from
(
select
a.CardNo
,charindex('-',a.cardNo,0) as separatorIndex
, len(a.cardNo) - charindex('-',a.cardNo,0) as Mark_length
, substring(a.CardNo,0,charindex('-',a.cardNo,0)) as Mark
, substring(a.CardNo,charIndex('-',a.cardNo,0)+1,1) as Mark1
, isnumeric(substring(a.CardNo,charIndex('-',a.cardNo,0)+1,1*1)) as isNumericMark1
, substring(a.CardNo,charIndex('-',a.cardNo,0)+2,1) as Mark2
, isnumeric(substring(a.CardNo,charIndex('-',a.cardNo,0)+2,1)) as isNumericMark2
, substring(a.CardNo,charIndex('-',a.cardNo,0)+3,1) as Mark3
, isnumeric(substring(a.CardNo,charIndex('-',a.cardNo,0)+3,1)) as isNumericMark3
from [Coll2012-13] a
) b
order by Mark,Mark1,Mark_length
Result:
CardNo separatorIndex Mark Mark_length Mark1
-------------------- -------------- -------------------- ----------- -----------
R-1 2 R 1 1
R-1A 2 R 2 1
R-2 2 R 1 2
R-2B 2 R 2 2
R-3 2 R 1 3
R-12 2 R 2 12
Hope this help.