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 2005 Forums
 Transact-SQL (2005)
 Cast Null to nvarchar

Author  Topic 

ias0nas
Starting Member

36 Posts

Posted - 2008-10-07 : 05:20:37
Hello,

Is there a way to cast a NULL value to an nvarchar, say, 'NULL'?

Thank you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 05:35:57
you cant cast NULL to nvarchar but that wont be equal to 'NULL'.NULL means some indeterminate value while 'NULL' is a valid character value.
Go to Top of Page

ias0nas
Starting Member

36 Posts

Posted - 2008-10-07 : 05:43:43
Thanks visakh,

I know that, I found an answer. I hate when that happens, googled it for half an hour and found the answer as soon as I posted that.
I found that:
coalesce(cast(withholding_country as varchar(20)), 'NULL') + '<||>'
which gives the characters 'NULL' if the field is NULL

Thank you
Go to Top of Page
   

- Advertisement -