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 |
dalibor
Starting Member
21 Posts |
Posted - 2012-03-07 : 02:38:10
|
Hi all,I have this table data:SELECT distinct AAAFROM <TABLE_A>--Obtain data:--A,B,C, NULL, MSELECT *FROM <TABLE_A>WHERE AAA <> 'M'--Obtain data:--A,B,C--But i need obtain data--A,B,C, NULL; I do not use UNION command. Is there a SET command, which would resolve this? How is this problem called? I did not know under what do I search the this forum.use MS SQL 2008 R2 Express database.Please help. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-07 : 03:13:01
|
just append or AAA IS NULL No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-07 : 23:37:56
|
quote: Originally posted by dalibor Hi all,I have this table data:SELECT distinct AAAFROM <TABLE_A>--Obtain data:--A,B,C, NULL, MSELECT *FROM <TABLE_A>WHERE AAA <> 'M'--Obtain data:--A,B,C--But i need obtain data--A,B,C, NULL; I do not use UNION command. Is there a SET command, which would resolve this? How is this problem called? I did not know under what do I search the this forum.use MS SQL 2008 R2 Express database.Please help.
The problem is due to fact that under default conditions, NULL is not stored as a value in SQL Server. It represents an unknown condition and not a value by itself. So none of operators =,>,<, etc will equate NULL values. So if you want to compare NULL values use IS NULL or IS NOT NULL as its represented internally as a bit and not as a value.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|