Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
In my table I want to display I am null when null value found in EmpName column and I am blank when blank value found in EmpName column, as table is designed, how to do this, please let me know
SQL
Create table #temp
(
	EmpID int,
	EmpName nvarchar(50)
)

-----------------------------------------

Insert into #temp Values(1,'Ram')
Insert into #temp Values(2,'')
Insert into #temp Values(3,Null)
Insert into #temp Values(4,'Shyam')
Insert into #temp Values(5,'')
Insert into #temp Values(5,Null)

-----------------------------------------

Select *, EmpName1=(CASE EmpName
WHEN NULL THEN 'I am Null'
WHEN '' THEN 'I am Blank'
ELSE EmpName
END) from #temp

-----------------------------------------
Posted
Updated 21-Sep-14 22:48pm
v2

1 solution

Hi,

Check this...


SQL
Select *, EmpName1=
CASE WHEN EmpName IS NULL THEN 'I am NULL'
WHEN EmpName='' THEN 'I am Blank'
ELSE EmpName
END
from #temp


Hope this will help you.

Cheers
 
Share this answer
 
Comments
Gihan Liyanage 22-Sep-14 5:19am    
Nice.. :)
Magic Wonder 22-Sep-14 5:48am    
Thanks... :-)

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