select identity(int,1,1) ID,* into #1 from  t1select a.c1,isnull(b.c2,0) c2 from #1 a left join #1 b on a.id=b.id+1