Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Problem with sql column formula -- null / concat

I've got the folowing formula for a computed column (LeadFullName) in the database design portion of vs2003.

([LeadFirstName] + ' ' + [LeadMidInitial] + ' ' + [LeadLastName])

Unfortuantely, Lead middle initial was added as a new column, so is null for all existing records. So all the existing records with null middle names show LeadFullName as null. I understand there are various ways to fix this, but I'm not sure how to implement in a formula.



Any help would be appreciated

Randy
[564 byte] By [blackbr] at [2007-11-11 10:08:10]
# 1 Re: Problem with sql column formula -- null / concat
Try this:

([LeadFirstName] + ' ' + COALESCE([LeadMidInitial], '') + ' ' + [LeadLastName])
Phil Weber at 2007-11-11 20:48:35 >
# 2 Re: Problem with sql column formula -- null / concat
Phil,

It worked perfectly! I had searched all over the internet, and only come up with ws_concat (which I couldn't get to work) and ifnull logic (that seemed pretty complex.

Thanks for the quick, Sunday reply!

Randy
blackbr at 2007-11-11 20:49:37 >