troubleshooting Question

SQL Concatonation in a SELECT not behaving as expected.

Avatar of splanton
splantonFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
5 Comments2 Solutions357 ViewsLast Modified:
I am concatonating some field values into a 'description' for an invoice. The only problem I can see is that the description appears empty when there are no InvoiceNotes.

Basically unless all the fields have values it appears to ignore the whole entry. ALL My WasteOrderDetail.JobRef rows have values but not all my WasteOrderDetail.InvoiceNotes rows will have.

The code I have is along these lines:

SELECT JobRef + ' - ' + ContainerSize.Description + ' ' + Container.Description + ' for ' + WasteType.Description +'. Notes: ' + WasteOrderDetail.InvoiceNotes as InvDescription
FROM WasteOrderDetail 
INNER JOIN Container ON WasteOrderDetail.ContainerId = Container.ContainerID
INNER JOIN ContainerSize ON WasteOrderDetail.ContainerSizeId = ContainerSize.ContainerSizeId
INNER JOIN WasteType ON WasteOrderDetail.WasteTypeId = WasteType.WasteTypeId 
WHERE ... etc

Is there any way round this?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros