34,587
社区成员
发帖
与我相关
我的任务
分享
select ID from t where id in (2,4,3,1)
order by charindex(','+rtrim(id)+',', ',2,4,3,1,')
declare @p varchar(100)
set @p='2,4,3,1' --参数
exec('
select ID from t where id in ('+@p+')
order by charindex('',''+rtrim(id)+'','','','+@p+','')
')