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
 General SQL Server Forums
 New to SQL Server Programming
 Null Value

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2012-02-24 : 10:34:29
Dear All,

I try to replace Null or blank field in the result by adding 'NOT AVAIL'as default in query ie.

ISNULL(PolicyHolder.AddressLineTwo,'NOT AVAIL')as Address2

In the output few of them will get replace with 'NOT AVAIL' but still the output contains blank field.How to replace with default value 'NOT AVAIL'if the feild has no value or null or blank.

Any help will be highly appreciated.

Thanks
SG

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-24 : 10:35:44
[code]ISNULL(NULLIF(PolicyHolder.AddressLineTwo,''),'NOT AVAIL')as Address2[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-24 : 10:46:13
quote:
Originally posted by satheesh

Dear All,

I try to replace Null or blank field in the result by adding 'NOT AVAIL'as default in query ie.

ISNULL(PolicyHolder.AddressLineTwo,'NOT AVAIL')as Address2

In the output few of them will get replace with 'NOT AVAIL' but still the output contains blank field.How to replace with default value 'NOT AVAIL'if the feild has no value or null or blank.

Any help will be highly appreciated.

Thanks
SG


the reason is NULL and blank are not the same
'' means blank value where NULL means unknown value its not stored as a value in table field but rather its stored as a bit internally to indicate that value is unknown

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-24 : 10:48:49
CASE WHEN PolicyHolder.AddressLineTwo IS NULL THEN 'NOT AVAIL'
WHEN PolicyHolder.AddressLineTwo IN ('', ' ') THEN 'NOT AVAIL'
ELSE PolicyHolder.AddressLineTwo
END
as Address2

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

satheesh
Posting Yak Master

152 Posts

Posted - 2012-02-24 : 11:14:01
Many Thank you to all.
Go to Top of Page
   

- Advertisement -