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 2000 Forums
 Transact-SQL (2000)
 null in VIEWS

Author  Topic 

Jason_D
Starting Member

11 Posts

Posted - 2002-07-18 : 12:03:52
I'm having some trouble with displaying information on a view. Can someone please help me out?

when i do the following in a view:

select a.name + b.name as EmployeeName

only rows with non null entries for both a.name and b.name appear (else a null value is displayed).

How do i make it such that a.name will appear even though b.name may be null.

Thanks!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-18 : 12:05:59
SELECT IsNull(a.name, '') + IsNull(b.name, '') AS EmployeeName FROM ...

That will cover both A and B in case either one is null.

Go to Top of Page

Jason_D
Starting Member

11 Posts

Posted - 2002-07-18 : 12:33:07
so simple, and yet so effective.

thanks Rob!

Go to Top of Page

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2002-07-18 : 15:13:19
If you have this problem consistently, set CONCAT_NULL_YIELDS_NULL OFF when you connect or whatever. If you use ADO, this is a dynamic property of the connection. Will save you a lot of headaches in queries like firstname + lastname, city + state + zip, etc.

Sarah Berger MCSD
Go to Top of Page
   

- Advertisement -