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)
 Replace Null Value in an Outer Join

Author  Topic 

Rfvgyhn
Starting Member

2 Posts

Posted - 2007-11-14 : 23:41:10
Let's say I have a query like this:

SELECT
A.asdf,
B.fdsa,
B.qwer
FROM table1 AS A LEFT OUTER JOIN
table2 AS B ON (some conditions)

If B.fdsa and B.qwer were to be null, how could I return a string like "nothing" instead of NULL?

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-15 : 00:01:59
IsNull(b.fdsa,'nothing')

or (Case when b.fdsa is null then 'nothing else b.fdsa end) as b.fdsa


if b.fdsa is a number though, could have issues...in that case make sure you cast b.fdsa as a varchar



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

Rfvgyhn
Starting Member

2 Posts

Posted - 2007-11-15 : 02:14:43
Great. Thanks. :)
Go to Top of Page
   

- Advertisement -