--前后两半部分的位数都不一致的情况下如何排序
DECLARE @t TABLE ( n VARCHAR(10) )
INSERT INTO @t
SELECT '13-1' union
SELECT '13-2' union
SELECT '13-4' union
SELECT '13-7' union
SELECT '13-3' union
SELECT '14-1' union
SELECT '13-8' union
SELECT '14-2' union
SELECT '13-9' UNION
SELECT '1-1' union
select '2-1' union
select '4-10' union
select '4-101'
SELECT n,
SUBSTRING(n,1,CHARINDEX('-',n)-1) AS 前半部分,
SUBSTRING(n,CHARINDEX('-',n)+1,LEN(n)-CHARINDEX('-',n)) AS 后半部分
FROM @t ORDER BY
--取出前半部分,并转为INT再排序
CONVERT(INT,SUBSTRING(n,1,CHARINDEX('-',n)-1)),
--取出后半部分,并转为INT再排序
CONVERT(INT,SUBSTRING(n,CHARINDEX('-',n)+1,LEN(n)-CHARINDEX('-',n)))