日期:2014-05-17 浏览次数:20808 次
SELECT 编号B ORDER BY REPLACE(编号B,'-','')*1 DESC
------解决方案--------------------
SELECT 编号B ORDER BY CAST(replace(编号B,'-','')AS INT) DESC
------解决方案--------------------
declare @T table([ID] int,[编号B] varchar(12)) insert @T select 1,'2012-08-68' union all select 2,'2012-06-36' union all select 3,'2012-12-1002' union all select 4,'2012-12-985' select * from @T ORDER BY LEFT([编号B],8),SUBSTRING([编号B],9,LEN([编号B])-8)*1 /* ID 编号B ----------- ------------ 2 2012-06-36 1 2012-08-68 4 2012-12-985 3 2012-12-1002 */