I\'m tryng to extract all pair say i,j from each element in a table against each element on the same table, here my query:
i,j
select a.Id L,b.id R into
So, just condition the join so that the left side is always equal to or lesser!
select a.Id L,b.id R into #cross from MyTable a inner join mytable b on a.id <= b.id