'#tmp1' content
ID | Name |
1 | Arvind |
2 | Kapil |
5 | Mohit |
8 | Rakesh |
SQL Statement
With missing as
(
Select 1 as mins, max(Id) as maxs from #tmp1
UNION ALL
Select mins + 1 , maxs from missing m
--Inner join #tmp1 t ON t.ID = m.mins
where mins < maxs
)
Select * from missing m
left outer join #tmp1 t ON t.ID = m.mins
where t.Id is null
Missing Identity
ID | Name |
3 | Raj |
4 | Mangesh |
6 | Rajesh |
7 | Ravindra |
No comments:
Post a Comment