select columns
into #t1 from tables
group by columns
having count(*) > 1
select identity(int,1,1) id,columns
into #t2
from #t1
order by columns
select id+1-(select min(id) from #t2 where column1=t.column1 and column2 = t.column2 idu_q
into #t3
from #t2 t
select columns from table as a,#t3 as b
where a.uid = b.uid and b.idu_q = 2