Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Find the Missing Records

Author  Topic 

lkiran086
Starting Member

21 Posts

Posted - 2014-07-15 : 06:25:20
Hi

I have a table contains one column.It has numbers 1 to 100 but some numbers are missing.

how can I find the missing numbers ?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-07-15 : 06:50:44
Try this:

select dt.number from
(select number from master..spt_values
where type = 'P' and
number between 1 and 100)dt
left join YourTable t on t.YourColumn = dt.number
where t.YourColumn IS NULL



Too old to Rock'n'Roll too young to die.
Go to Top of Page

lkiran086
Starting Member

21 Posts

Posted - 2014-07-16 : 09:10:16
Thanks
Go to Top of Page
   

- Advertisement -