You are here: Re: Nulls in columns additions when 1 or more column values is blank « MsSQL Server « IT news, forums, messages
Re: Nulls in columns additions when 1 or more column values is blank

Posted by Techhead on 06/04/07 21:32

On Jun 4, 3:29 pm, "Plamen Ratchev" <Pla...@SQLStudio.com> wrote:
> You can use COALESCE, something like this will do it:
>
> COALESCE(P.ADDR1, '') + ' - ' + COALESCE(P.CITY, '') + ', ' +
> COALESCE(P.STATE, '') AS LOCATION
>
> Also, you can play with formatting variations based on what you want to get
> when one of the columns is NULL, like this:
>
> COALESCE(P.ADDR1, '') + COALESCE(' - ' + P.CITY, '') + COALESCE(', ' +
> P.STATE, '') AS LOCATION
>
> HTH,
>
> Plamen Ratchevhttp://www.SQLStudio.com

Somebody at work told me to use this:

SELECT CASE WHEN P.STATE IS NULL THEN '' ELSE P.STATE END

It seems to work. Is this similar as to what is described above?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация