日期:2014-05-18  浏览次数:20544 次

SQL Server2000 按照指定ID顺序排序问题???

select * from v_like_productlist where id in 
(13423,28783,11992,32385,14497,2974,23620,15798,913,83,3179,7455,6104,13412,38645,25110,37047,17772,33356,34095,13439,38091,37994,2229,21210,34759,2036,37339,34697,1247,819) 
order by charindex(cast(id as varchar),'13423,28783,11992,32385,14497,2974,23620,15798,913,83,3179,7455,6104,13412,38645,25110,37047,17772,33356,34095,13439,38091,37994,2229,21210,34759,2036,37339,34697,1247,819')

------解决方案--------------------
order by charindex(','+cast(id as varchar)+',',',13423,28783,11992,32385,14497,2974,23620,15798,913,83,3179,7455,6104,13412,38645,25110,37047,17772,')