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
 General SQL Server Forums
 New to SQL Server Programming
 where clause with NULL

Author  Topic 

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2008-10-29 : 02:06:52
query

select * from table1 where project is null


return nothing, eventhiugh ther are empty values in column project

please help

thanks

onlyforme
Starting Member

25 Posts

Posted - 2008-10-29 : 02:52:56
for empty values u want to specify as
select * from table1 where projest=''

select * from table1 where project is null-- will return only the columns having null values.
Go to Top of Page

krishna_yess
Yak Posting Veteran

81 Posts

Posted - 2008-10-29 : 02:56:29
thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-29 : 05:17:18
if you want both records with null and '' use this

select * from table1 where nullif(project,'') is null
Go to Top of Page

ursangel
Starting Member

17 Posts

Posted - 2008-10-29 : 09:16:59
to be on the safer side always check for isnull and use it in the where clause

select * from table1 where isnull(project, '') = ''

Regards
Angel
Go to Top of Page
   

- Advertisement -