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 2005 Forums
 Transact-SQL (2005)
 NOT IN

Author  Topic 

zaurska
Starting Member

12 Posts

Posted - 2008-09-06 : 22:07:04
Can anyone tell me if there is a volume limit on using NOT IN?

I use it on a table with 3782 rows and it does not work.

If I make a copy of the table with 3782 rows and delete 3700 of the rows NOT IN works.

I'm trying to find missing dates


declare @bd datetime
declare @ed datetime

Set @bd ='20080906'
Set @ed ='20080910'

DECLARE @tempTable table (D datetime)

While @bd<=@ed
Begin
Insert @tempTable (D) Values(@bd)
Set @bd=dateadd(day,1,@bd)
End

SELECT D
FROM @tempTable
where D
NOT IN( select shortDate
from weighttblCOPY)

zaurska
Starting Member

12 Posts

Posted - 2008-09-06 : 23:29:00
Sorry. Complete red herring.

I should have been using NOT EXISTS.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-07 : 00:18:55
you can use LEFT JOIN also

SELECT t.D 
FROM @tempTable t
LEFT JOIN weighttblCOPY w
ON w.shortDate=t.D
where w.shortDate IS NULL

Go to Top of Page
   

- Advertisement -