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.
| Author |
Topic |
|
nitinbobde
Starting Member
1 Post |
Posted - 2011-09-29 : 23:21:12
|
| Hi,I am facing problem in where condition with null value column with varchar datatype.when i do select * from emp where empname is null---this statement works but when i doselect * from emp where empname=''--no records returnedHow to handle this , i dont want to change the datatype .Pleas help!! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-09-30 : 00:01:11
|
| help with what? What is the problem? Null is not the same as ''. To find Null values you have to use "where <col> is null"The same would apply to any datatype.Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-30 : 01:25:14
|
| please understand that NULL is not considered as a value under default settings. It just represents value unknown situation hence none of operators like =,>,< etc will return NULL valued records. So as TG suggested you need to use IS NULL ,IS NOT NULL for evaluation of NULL values.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Reporter
Starting Member
48 Posts |
Posted - 2011-09-30 : 05:32:05
|
| select * from emp where nullif(empname,'') is null |
 |
|
|
|
|
|