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
 coalesce

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2008-03-11 : 10:26:57
Here is my statement

COALESCE (Reg_HomeAdd1, N'') + N', ' + COALESCE (Reg_HomeAdd2, N'') + N', ' + COALESCE (Reg_HomeAdd3, N'') + N', ' + COALESCE (Reg_HomeAdd4, N'')

if one of the fields is null how do I stop two commas showing

ie

The Nook,West Street,,Townsville

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-11 : 10:28:46
Put the commas in the COALESCE...

COALESCE (Reg_HomeAdd1, N'') + COALESCE (N', ' + Reg_HomeAdd2, N'') + COALESCE (N', ' + Reg_HomeAdd3, N'') + COALESCE (N', ' + Reg_HomeAdd4, N'')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-11 : 10:30:26
Try:-

COALESCE (Reg_HomeAdd1 + N', ', N'') + COALESCE (Reg_HomeAdd2+ N', ' , N'') + COALESCE (Reg_HomeAdd3+ N', ', N'') + COALESCE (Reg_HomeAdd4, N'')
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2008-03-11 : 10:39:26
Great - thanks
Go to Top of Page
   

- Advertisement -