select col=a1.id+','+a2.id+','+a3.id+','+a4.id+','+a5.id+','+a6.id+','+a7.id
from @t a1,@t a2,@t a3,@t a4,@t a5,@t a6,@t a7
where a1.id<a2.id
and a2.id<a3.id
and a3.id<a4.id
and a4.id<a5.id
and a5.id<a6.id
and a6.id<a7.id
declare @t table(id varchar(10))
insert @t select 0
union all select 1
union all select 2
union all select 3
union all select 4
union all select 5
union all select 6
union all select 7
union all select 8
union all select 9
--组合数
select col=a1.id+','+a2.id+','+a3.id+','+a4.id+','+a5.id+','+a6.id+','+a7.id
from @t a1,@t a2,@t a3,@t a4,@t a5,@t a6,@t a7
where a1.id<a2.id and a2.id<a3.id and a3.id<a4.id and a4.id<a5.id and a6.id<a7.id