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.
| Author |
Topic |
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-12-22 : 10:30:21
|
| Hi, I want to prevent null values from a subquery, so I try this:( select TitleName from EapcTitle where cast(TitleID as varchar(20)) = upd.Title, CASE TitleName WHEN TitleName is not null then Titlename Else '' End ) as Title,But it isn't working, so what should I change? |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-12-22 : 10:52:04
|
| [code](select COALESCE(TitleName,'') from EapcTitle where cast(TitleID as varchar(20)) = upd.Title,) as Title,[/code] |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-12-22 : 10:52:47
|
| Ohhh, yeah Coalesce, I keep forgetting...The secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-12-22 : 10:55:57
|
| Actually, I still see NULL'sThe secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-22 : 10:56:15
|
| 1st : Your case statement is in the wrong place (Select Case when....ELSE...END as Name From.....)2nd: you could probably do -COALESCE((select TitleName from EapcTitle where cast(TitleID as varchar(20)) = upd.Title), '') as Title Edited for correctness |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-12-22 : 11:05:02
|
| Yup, that workedThe secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
|
|
|
|
|