|
-
Dec 6th, 2017, 08:18 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] MS Sql Server - not filtering on Null?
Hi,
Got a weird one. I have two simple sql statements.
Code:
select top 10 *
from tablename
where idfield is null
SELECT top 10
pb.*
from tablename pb
The first returns no records.
The second returns ten records, of which the idfield is null.
Any ideas why MS Sql server isnt filtering correctly?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Dec 6th, 2017, 08:50 AM
#2
Thread Starter
Don't Panic!
Re: [RESOLVED] MS Sql Server - not filtering on Null?
Found it
The first I had pointed to a view (which got rid of nulls) the second was the table. Both had very similar names. Not ones I created, but I should have seen it.
All sorted and makes sense now.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Dec 6th, 2017, 08:11 PM
#3
Re: [RESOLVED] MS Sql Server - not filtering on Null?
This is an example of why it's a good idea to post the actual code if you can. Simplifying things can have its benefits but, as we're not as close to the problem, I'll wager that we'd have noticed the different names immediately, if those names had actually been posted. If a simplified example seems warranted, I'd probably recommend that in addition to the actual code, rather than instead of it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|