Home > Archive > MS SQL Server > July 2005 > Concatenate









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Concatenate
gmead7

2005-07-11, 1:23 pm

I'm trying to concatenate First name, Middle Initial and Last Name. Many
records do not have a middle initial (middle initial is NULL) therefore
causing the concatenation to yield a Null result. Is there an easy trick /
technique to fix this? thanks
Anith Sen

2005-07-11, 1:23 pm

You can use COALESCE or ISNULL to replace the NULLs to spaces like:

SELECT first_name + COALESCE( middle_initial, '' ) +
COALESCE( last_name, '' ) AS "full name"
FROM ...

--
Anith


gmead7

2005-07-11, 1:23 pm

Thank You!

"Anith Sen" wrote:

> You can use COALESCE or ISNULL to replace the NULLs to spaces like:
>
> SELECT first_name + COALESCE( middle_initial, '' ) +
> COALESCE( last_name, '' ) AS "full name"
> FROM ...
>
> --
> Anith
>
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com