Solved

Compound Field Expression in Query is BLANK

Posted on 2003-12-03
5
297 Views
Last Modified: 2012-08-14
I use the following query to run a report in my database:

*****************************************************
SELECT TBL_CASE.CID,
    TBL_PLAINTIFF.PLNAME + ', ' + TBL_PLAINTIFF.PFNAME + ' ' + TBL_PLAINTIFF.PMI
     + ' ' + TBL_PLAINTIFF.Sufix AS pltFull, TBL_PLAINTIFF.SSN,
    TBL_PLAINTIFF.DOB, TBL_PLAINTIFF.DOD,
    TBL_PLAINTIFF.PADDRESS, TBL_PLAINTIFF.AKA,
    TBL_PLAINTIFF.diagnosis, TBL_CASE.[CAUSE NUMBER],
    TBL_CASE.[STYLE PLAINTIFF],
    TBL_CASE.[STYLE DEFENDANT], TBL_CASE.COURT,
    TBL_COUNTY.COUNTY, TBL_PLAINTIFF.[Pltf ID],
    TBL_PLAINTIFF.Occupation, TBL_CASE.comments,
    TBL_PLAINTIFF.[work site], TBL_PLAINTIFF.Settled,
    TBL_PLAINTIFF.[DE comments]
FROM dbo.TBL_CASE INNER JOIN
    dbo.[TBL_PETITION OF ENTRY] ON
    dbo.TBL_CASE.CID = dbo.[TBL_PETITION OF ENTRY].CID INNER
     JOIN
    dbo.TBL_PLAINTIFF ON
    dbo.[TBL_PETITION OF ENTRY].PID = dbo.TBL_PLAINTIFF.PID INNER
     JOIN
    dbo.TBL_COUNTY ON
    dbo.TBL_CASE.CNTYID = dbo.TBL_COUNTY.CNTYID
*****************************************************

The query column in question is the expression which creates the [pltFull] column.  It combines the first, middle, last name and suffix fields to display an individual's full name as "Doe, John A. Jr." etc....  What I have found, however, is if ALL FOUR component fields to this expression are not populated, then NO value is returned.

My question is what is the quickest and most efficient method to have the query return full names, even if the middle initial field or suffix field is not populated?
0
Comment
Question by:FunkiNATEr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 9

Accepted Solution

by:
PaulBarbin earned 500 total points
ID: 9872608
Typically first and last are required, so you might not need it on all columns.
Use the ISNULL method:

TBL_PLAINTIFF.PLNAME + ', ' + TBL_PLAINTIFF.PFNAME + ' ' + ISNULL(TBL_PLAINTIFF.PMI, '')
     + ' ' + ISNULL(TBL_PLAINTIFF.Sufix, '') AS pltFull, TBL_PLAINTIFF.SSN,

Paul
0
 
LVL 8

Expert Comment

by:Dishan Fernando
ID: 9872615
not populated mean NULL VALUES OR BLANK '' Column??
0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9872622
If you don't already know then the reason this happens is that one of those columns is NULL.  NULL means UNKNOWN, and UNKNOWN plus anything is still UNKNOWN.

Another way to solve this problem is by changing a db option CONCAT_NULL_YIELDS_NULL
by running
SET CONCAT_NULL_YIELDS_NULL OFF

Paul

0
 
LVL 9

Expert Comment

by:PaulBarbin
ID: 9875406
I appreciate the points and the grade.
0
 

Author Comment

by:FunkiNATEr
ID: 9875414
No problem -- I am sure I will have more in the near future.  :-)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question