Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where not in... - not working

Status
Not open for further replies.

lisat76

Programmer
Sep 25, 2007
89
US
I have a SQL database table that i import data into from an access database. The id in the sql DB is varbinary while the id in the access db is text so i convert the text to varbinary in my query. That seems to work.
When i have an issue is when i do a "not in" in the where clause. I do this so if the product is already in the db i don't want it imported again.
However if i add a where clause i get no results even though i am positive the ID is not in the sql database.
MAtter of fact if i change the where to be "IN" instead of "not in" I still get no results.
I have done queries like this several times with no issues, I must be missing something in my syntax. If i just run the query without the where clause it works just fine.
Here is my syntax

Code:
SELECT  convert (varbinary(1000),[ID]) as ID,[product]
From
OPENROWSET('Microsoft.Jet.OLEDB.4.0','d:\db\products\products.mdb';
'admin';'',products)as s1 where s1.ssn not in
   (select PRID from store.dbo.products as PD
inner join productinfo as P on P.PRid =PD.PRID  
where P.term_date is null)
 
are you sure ssn and prid are the same thing? Wouldn;t you want where ID not in?

"NOTHING is more important in a database than integrity." ESquared
 
oh i made a mistake typing the query here but it is id in my real query here is is again
Code:
SELECT  convert (varbinary(1000),[ID]) as ID,[product]
From
OPENROWSET('Microsoft.Jet.OLEDB.4.0','d:\db\products\products.mdb';
'admin';'',products)as s1 where s1.ID not in
   (select PRID from store.dbo.products as PD
inner join productinfo as P on P.PRid =PD.PRID  
where P.term_date is null)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top