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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Find the Missing Records
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

21 Posts

Posted - 07/15/2014 :  06:25:20  Show Profile  Reply with Quote

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 ?

Flowing Fount of Yak Knowledge

8781 Posts

Posted - 07/15/2014 :  06:50:44  Show Profile  Visit webfred's Homepage  Reply with Quote
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

Starting Member

21 Posts

Posted - 07/16/2014 :  09:10:16  Show Profile  Reply with Quote
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000