all groups > sql server programming > august 2005 >
You're in the

sql server programming

group:

concatenate multiple fields


RE: concatenate multiple fields KH
8/1/2005 6:50:01 PM
sql server programming:
If by "not work" you mean the seconds example is NULL, then it's because the
middle name field is NULL -- concatenating any char field with NULL yeilds
NULL; mathmatical, bitwise, and other operations have similar behavior.

Anyways this is a display issue and would be better handled by your client
code, but for some solutions, in BOL look up:
- ISNULL
- COALESCE
- SET CONCAT NULL YIELDS NULL



[quoted text, click to view]
Re: concatenate multiple fields --CELKO--
8/1/2005 7:30:39 PM
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files.

What the heck does "will not work" mean?? Would you like to go to a
doctor that tells you something like that? Why did you use a reserved
word for a table name??

My guess -- based on absolutely nothing you told us -- is that you
have NULL-able columns and do not know that NULLs propagate, one of the
most basic priniciples in SQL.
concatenate multiple fields jeff fisher
8/1/2005 7:47:23 PM
I don't have any troubles concatenating two fields together but so far, I
haven't been able to concatenate more than two fields.
(Order.FirstName+' '+order.LastName) as Name
will work
(Order.FirstName+' '+ order.MiddleName+ ' '+order.LastName) as Name
will not work.

Re: concatenate multiple fields Robbe Morris [C# MVP]
8/1/2005 9:14:20 PM
I can't think of any reason that shouldn't work.
What is the exact error?

Is this a problem you see in Query Analyzer or
via your "client" code such as ASP or ASP.NET?

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp



[quoted text, click to view]

AddThis Social Bookmark Button