Neil Toulouse
Programmer
Hi guys!
I have a bit of a weird problem which is making me think there is something worng with the database itself, but don't really know where to look!
Basically there are two tables, and the query I am running is to only show values from Table 1 where there is no relating record in Table 2:
So the query I am running is:
This should therefore return the 'Neil' record from Table1 (shouldn't it??), but instead it returns nothing.
I have checked and the record is definately not in Table 2, so I would expect a result.
To test this further I tried a similar query on another customer's data and it works as expected, ie the record is returned.
Going back to the original dataset, I have removed and re-created all the indexes, and have run the DBCC CHECKDB which shows no errors.
Can anyone advise where I can go from here to sort this out?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...
I have a bit of a weird problem which is making me think there is something worng with the database itself, but don't really know where to look!
Basically there are two tables, and the query I am running is to only show values from Table 1 where there is no relating record in Table 2:
Code:
Table 1
-------
PK1 1
Name FatSlug
PK1 2
Name Neil
PK1 3
Name John
Table 2
-------
PK2 10
PK1 1
Address The Road
PK2 11
PK1 3
Address The Street
So the query I am running is:
Code:
SELECT * FROM Table1 WHERE PK1 NOT IN(SELECT PK1 FROM Table2)
This should therefore return the 'Neil' record from Table1 (shouldn't it??), but instead it returns nothing.
I have checked and the record is definately not in Table 2, so I would expect a result.
To test this further I tried a similar query on another customer's data and it works as expected, ie the record is returned.
Going back to the original dataset, I have removed and re-created all the indexes, and have run the DBCC CHECKDB which shows no errors.
Can anyone advise where I can go from here to sort this out?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...