Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Frnds,
I am having Table

Table1
      ID        Name       Dept
       1          A        NULL
       2          B         IT
       3          C         IT
       4          D         NULL
 

i need output as follows

   ID        Name       Dept
    1          A        NULL
    4          D         NULL

I used
select * from Table1 where Dept!='IT' (also where Dept<>'IT')

this query not getting,how to get values
Posted

Hi, try this:
SQL
select * from Table1 where Dept!='IT' OR Dept IS NULL


More info here: http://msdn.microsoft.com/en-us/library/ms191504.aspx[^]
 
Share this answer
 
Comments
itsureshuk 24-Jan-13 8:15am    
thnks
Hello freind

can you try this...

SQL
--If you want to get All NULL value
SELECT * FROM Table1 WHERE Dept IS NULL

--If you want to get All which are not NULL value
SELECT * FROM Table1 WHERE Dept IS NOT NULL
 
Share this answer
 
Comments
itsureshuk 24-Jan-13 8:15am    
thnks
You can't compare to NULL.

Try this:
select * from table1 where Dept is null;
 
Share this answer
 
Comments
itsureshuk 24-Jan-13 8:15am    
thnks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900