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)
 Quick Null Question

Author  Topic 

ZMike
Posting Yak Master

110 Posts

Posted - 2008-11-18 : 08:58:36
I wanted Null fields to show as blank. In another view I had made a query for certain services that I'm joining to a new query. In the final version I want any Null fields to show as ' '

(CASE WHEN [Services].[Service] IS NULL THEN ' ' ELSE [Services].[Service] END) AS [Service]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 09:00:26
just use COALESCE([Services].[Service] ,'')
Go to Top of Page

ZMike
Posting Yak Master

110 Posts

Posted - 2008-11-18 : 09:01:23
Nevermind it worked. I didnt see my extra field on the end of my select list... Sorry about that.
Go to Top of Page

ZMike
Posting Yak Master

110 Posts

Posted - 2008-11-18 : 09:03:02
visakh16,

I'll have to check that out I was looking around on the forums and read some post about COALESCE.

Thanks !

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 09:08:41
quote:
Originally posted by ZMike

visakh16,

I'll have to check that out I was looking around on the forums and read some post about COALESCE.

Thanks !




Welcome
Go to Top of Page

asgast
Posting Yak Master

149 Posts

Posted - 2008-11-18 : 11:17:05
use
isnull([Services].[Service], '') as [Service]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 12:33:35
quote:
Originally posted by asgast

use
isnull([Services].[Service], '') as [Service]


both are fine. But in some cases coalesce is found better because of following reason

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/10/04/isnull-or-coalesce.aspx
Go to Top of Page
   

- Advertisement -