Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating a null value to a string

Status
Not open for further replies.

PreacherUK

Technical User
Sep 26, 2002
156
NL
Hi all,
I have a table containing a number of fields. Two of those fields contain strings I need to concatenate to display the whole name of an item. Occasionally one of the fields is NULL, which is a failing of the data scource, so theres not much I can do from that end.

This seems to be resulting in null being returned when one of the fields is null, rather than the name from the other field+null.

is there a way of treating this?
 
Check out the ISNULL function in BOL. It will substitute a value when NULL is encountered. Somthing like this:

Code:
SELECT FirstName + IsNull(MI, '') + LastName
FROM Customers

Also check out COALESCE and their cousin, NULLIF. Good luck!

--Angel [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top