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 2005 Forums
 Transact-SQL (2005)
 Checking for null

Author  Topic 

sross81
Posting Yak Master

228 Posts

Posted - 2008-05-23 : 18:12:00
I have a table that I know has a null or nothing in a field. When I run this query to get a list of them nothing comes back at all but it doesn't error out. Any ideas?

select *
from lab_test_add_conf
where table_name = null
order by lab_test_conf_id

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-23 : 18:14:48
where table_name is null

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

sross81
Posting Yak Master

228 Posts

Posted - 2008-05-23 : 18:16:23
I tried where table_name is null and it didn't work either.

I just got this to work:

select *
from lab_test_add_conf
where table_name = ' '
order by lab_test_conf_id
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-23 : 18:22:43
Then your data does not have nulls in it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

sross81
Posting Yak Master

228 Posts

Posted - 2008-05-23 : 18:24:05
Well its blank? Is a null and blank different?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-23 : 18:28:15
Yes. One is a value and the other isn't.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page
   

- Advertisement -