declare @t1 table (id int,field nvarchar(5))
insert into @t1 select 3,N'记录1'
union all select 2,N'记录2'
union all select 1,N'记录2'
union all select 2,N'记录1'
union all select 3,N'记录2'
union all select 1,N'记录1'
select *
from @t1
where id in (1,2)
order by
case id
when 1 then 1
when 2 then 2
end
/
declare @t1 table (id varchar(5),field nvarchar(5))
insert into @t1 select 3,N'记录1'
union all select 2,N'记录2'
union all select 1,N'记录2'
union all select 2,N'记录1'
union all select 3,N'记录2'
union all select 1,N'记录1'
select *
from @t1
where id in (1,2)
order by charindex (','+id+',',',1,2,')