View Full Version : Data


sven2
09-09-2009, 09:46 PM
Hello,

to retrieve data from a table I use the following code:

strSQL = strSQL & " LEFT(UPPER(Werknemers.Achternaam),1) + LOWER(RIGHT(Werknemers.Achternaam,LEN(Werknemers.A chternaam)-1)) "
strSQL = strSQL & " + ' ' + LOWER(Werknemers.Tussenvoegsel), "
strSQL = strSQL & " LEFT(UPPER(Werknemers.Voornaam),1) + LOWER(RIGHT(Werknemers.Voornaam,LEN(Werknemers.Voo rnaam)-1)) "

Everything is just working fine if there is data in the fields achternaam, voornaam and tussenvoegsel. The problem is that the fields voornaam and tussenvoegsel can be empty. If that is the case there is no data showed ...

How can I solve this problem?

Thanks in advance,
Sven.

namliam
09-10-2009, 12:59 AM
That is because Null + 'Something' = Null.

You are looking for Coalesce or Isnull (http://databases.aspfaq.com/database/coalesce-vs-isnull-sql.html) functions to replace the null by an empty string

Make sure to add trim in there as well to prevent double spacing when there is no tussenvoegsel.

Greetings from Amsterdam :)