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 2012 Forums
 Transact-SQL (2012)
 Null and IS NOT Null

Author  Topic 

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-08-12 : 23:17:17
Hello,

How do I query CASE for data that has Null and Not Null. Here is my simple query:

Select HomeAddress
From RealEstate

output: (5 records)
Null
20 Park Street
Null
Null
Null

How do I write CASE Statement, if Null then 'Empty' and if its NOT NUll then 'Not Empty' ?

Anyone can help?

stepson
Aged Yak Warrior

545 Posts

Posted - 2014-08-13 : 00:47:00
[code]Select
HomeAddress
,CASE WHEN HomeAddress IS NULL THEN 'Empty'
ELSE 'Not Empty' END AS caseStmt
From RealEstate
[/code]


sabinWeb MCP
Go to Top of Page

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2014-08-13 : 23:45:18
Thank you Stepson.It worked.

SQLBoy
Go to Top of Page
   

- Advertisement -