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
 A DOUBT WITH NULL

Author  Topic 

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-11-11 : 04:30:38
HI,
suppose i have column called name and this column can be null.
so if i do the the checking in the query
select * from table where name <> ''.
will this query consider nulls

pls reply

ok tanx..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-11 : 04:32:51
nope. under default settings NULL is not considered as a value so <> ignores NULL
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-11-11 : 04:42:08
ok tanx,
the only checking we can made directly with null is -- column is null in where condition of query right..

and besides we can use isnull and coaelesce functions
am i right?

ok tanx....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-11 : 04:45:29
yup. Unless you've changed default ANSI NULLS setting
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-11 : 05:17:45
If you want to have null values too,

select * from table where name <> '' or name is null


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AShehzad
Starting Member

8 Posts

Posted - 2008-11-11 : 06:30:09
You may visit following blog link for very basic understanding of NULL http://dbdigger.blogspot.com/2008/05/null-in-sql-server.html

Atif Shehzad
DBA Pakistan Revenue Automation Limited
Go to Top of Page
   

- Advertisement -