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 2000 Forums
 Transact-SQL (2000)
 Problem with sql statement

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2004-11-01 : 04:20:20
I am runnign the follwing sql
select * from users where and status1!=4


Now I have 5 records wehre status1 is null and they are not being returned.

Does anyone have any idea why not?

sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2004-11-01 : 04:29:41
Hi

Please try the queries below.

select * from users where and (status1!=4 or status1 is null)


Or


select * from users where and isnull(status1,'')!=4
Go to Top of Page

surefooted
Posting Yak Master

188 Posts

Posted - 2004-11-01 : 10:07:26
Or you can SET ANSI_NULLS OFF, depends on your other requirements.

-Jon
Should still be a "Starting Member" .
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-01 : 11:15:01
maybe it was a typo on your part but you don't need AND
change
select * from users where and status1!=4
to
select * from users where status1!=4

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -