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
 General SQL Server Forums
 New to SQL Server Programming
 Looking for code improvement

Author  Topic 

weitzhandler
Yak Posting Veteran

64 Posts

Posted - 2009-02-21 : 20:49:24
I am using this code in an Auto Computed column ("FullAddress").
the code looks really ugly, any improvements will be really appreciated.


(CASE WHEN (ISNULL(AddressI, '') = '') THEN '' ELSE AddressI + CHAR(10) + CHAR(13) END) +
(CASE WHEN (ISNULL(AddressII, '') = '') THEN '' ELSE AddressII + CHAR(10) + CHAR(13) END) +
(CASE WHEN (ISNULL(City, '') = '') THEN '' ELSE City + ', ' END) +
(CASE WHEN (ISNULL([State], '') = '') THEN '' ELSE [State] + ' ' END) + ZIP +
(CASE WHEN (ISNULL(Country, '') = '') THEN '' ELSE CHAR(10) + CHAR(13) + Country END)


Shimmy

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-22 : 00:54:08
doesnt look too bad for me. as values are from different fields, this is the way to go.
Go to Top of Page
   

- Advertisement -