日期:2014-05-18 浏览次数:20652 次
select top 33 identity(int,1,1) id into #t from sys.objects select a.id id1,b.id id2,c.id id3,d.id id4,e.id id5,f.id id6 from #t a cross join #t b cross join #t c cross join #t d cross join #t e cross join #t f where a.id<>b.id and a.id<>c.id and a.id<>d.id and a.id<>e.id and a.id<>f.id and b.id<>c.id and b.id<>d.id and b.id<>e.id and b.id<>f.id and c.id<>d.id and c.id<>e.id and c.id<>f.id and d.id<>e.id and d.id<>f.id and e.id<>f.id /*结果 id1,id2,id3,id4,id5,id6 ----------------------- 4 6 5 2 3 1 4 7 5 2 3 1 4 8 5 2 3 1 4 9 5 2 3 1 4 10 5 2 3 1 4 11 5 2 3 1 4 12 5 2 3 1 4 13 5 2 3 1 4 14 5 2 3 1 4 15 5 2 3 1 4 16 5 2 3 1 4 17 5 2 3 1 4 18 5 2 3 1 4 19 5 2 3 1 4 20 5 2 3 1 4 21 5 2 3 1 4 22 5 2 3 1 4 23 5 2 3 1 4 24 5 2 3 1 4 25 5 2 3 1 ... ... ... */