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)
 isnull multiple conditions

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2008-02-14 : 13:21:42
I have the following:

isnull(b.NAME,ms.name) as SecurityDescription

I want to add a second source if you will that says, if its still null after using ms.name, than grab a name from another field. Is it possible???

tprupsis
Yak Posting Veteran

88 Posts

Posted - 2008-02-14 : 13:27:36
Did you try nesting? isnull(b.NAME,isnull(ms.name,OtherField))
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2008-02-14 : 13:32:01
I did not, but just did and it works, didnt realize it was possible. Thanks for your time
Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2008-02-14 : 13:33:25
or coalesce()

Jay
to here knows when
Go to Top of Page

Qualis
Posting Yak Master

145 Posts

Posted - 2008-02-14 : 15:35:29
Coalesce(b.NAME, ms.name, ...)
Where ... is as many other fields as you want to use!
Go to Top of Page
   

- Advertisement -