| Author |
Topic |
|
h2sut
Starting Member
40 Posts |
Posted - 2008-05-14 : 15:56:18
|
| How would i use a coalesece on this function to get null. if i use coalesce(xxxxx,0). If there is nothing in there it returns a blank space but i need to put null in there cast([DPVisionPlan] as nvarchar(255)) [DPVisionPlan], |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-14 : 16:00:35
|
| You wouldn't use COALESCE as that functions is used to replace NULL values with something else. You want the reverse. Try REPLACE function instead.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
h2sut
Starting Member
40 Posts |
Posted - 2008-05-14 : 16:04:29
|
| I want to use the coalese(xxxx,0) but not sure how it goes in cast([DPVisionPlan] as nvarchar(255)) [DPVisionPlan], |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-14 : 16:08:28
|
| You can't use COALESCE as it does the opposite of what you want.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-05-14 : 16:58:24
|
| NULLIF() maybe? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-14 : 23:38:43
|
quote: Originally posted by h2sut How would i use a coalesece on this function to get null. if i use coalesce(xxxxx,0). If there is nothing in there it returns a blank space but i need to put null in there cast([DPVisionPlan] as nvarchar(255)) [DPVisionPlan],
use NULLIFNULLIF(cast([DPVisionPlan] as nvarchar(255)),' ') AS [DPVisionPlan], |
 |
|
|
h2sut
Starting Member
40 Posts |
Posted - 2008-05-15 : 12:09:14
|
| Hello all the Nullif worked. Many thanks to all who help. ttyl |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jdaman
Constraint Violating Yak Guru
354 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|