Use the COALESCE function. It returns the first non-null value:

SELECT COALESCE(mycolumn, "default value") AS someField
FROM table_name

If any row for the mycolumn field returns null, the null value will replaced
with the string "default value".

<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: Mark Leder [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 13, 2006 8:18 AM
To: CF-Talk
Subject: SQL Concetenation inside CFQuery


I'm using this cfquery to pull records from an MSSQL 2005 db:

SELECT U.userID, U.userFirstName, U.userMiddleName, U.userLastName,
(U.userFirstName + SPACE(1) + U.userMiddleName + SPACE(1) + U.userLastName)
AS assignedName
   FROM a_Table

It works great, with one exception. In some cases, the U.userMiddleName
datafield is a NULL value.  When that occurs, the entire "assignedName"
alias is NULL for that record row, not just inserting an empty space between
the first and last names as I would expect.  When all three datafields
(first,middle,last) have values, a valid "assignedName" is returned.  Is
there a workaround?

Thanks,
Mark


[This E-mail scanned for viruses by Declude EVA]





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263922
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to