SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Find the Missing Records
 New Topic  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

8780 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000