create table #T(id int, col varchar(10))
insert into #T select 1,'A'
insert into #T select 2,'B'
insert into #T select 3,'C'
insert into #T select 4,'D'
declare @str1 varchar(10),@str2 varchar(10),
@str3 varchar(10),@str4 varchar(10)
--1
select @str1=isnull(@str1,'')+col
from
(
select top 2 id,col from #T order by id
) A
order by id
--2
select @str2=isnull(@str2,'')+col
from
(
select top 2 id,col from #T order by id
) A
order by id desc
--3
select @str3=isnull(@str3,'')+col
from
(
select top 2 id,col from #T order by id desc
) A
order by id
--4
select @str4=isnull(@str4,'')+col
from
(
select top 2 id,col from #T order by id desc
) A
order by id desc
--result
select @str1,@str2,@str3,@str4
Drop table #T