Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String+NULL = NULL but not in SQL Server
Message
De
11/05/1999 06:12:12
Marco Beuk
Innovero Software Solutions
The Hague, Pays-Bas
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
String+NULL = NULL but not in SQL Server
Divers
Thread ID:
00217101
Message ID:
00217101
Vues:
57
SELECT company.name + person.name as desc
FROM employees
LEFT OUTER JOIN company ON employees.compid = company.id
LEFT OUTER JOIN person ON employees.persid = person.id

In SQL Server (query analyzer) name will allways be filled as long as one of the two joins succeed.
In VFP (SPT) name will only be filled if both joins succeed, otherwise name is NULL. (Regardless of ANSI_NULL setting)

I know that String+NULL = NULL in VFP but not in SQL Server!

Even if i modify the statement to the following name will be null in VFP:
SELECT CASE employees.compid WHEN NULL THEN '' ELSE company.name END + CASE employees.persid WHEN NULL THEN '' ELSE person.name as name END AS desc
FROM employees
LEFT OUTER JOIN company ON employees.compid = company.id
LEFT OUTER JOIN person ON employees.persid = person.id

An interesting point is that when i say ... CASE 1 WHEN 1 THEN '*' ELSE .... I do get the asterix but when i say ... CASE NULL WHEN NULL THEN '*' i don't.

Does anybody know what is happening here?
Thanks in advance,
Marco.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform