Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String+NULL = NULL but not in SQL Server
Message
From
11/05/1999 06:12:12
Marco Beuk
Innovero Software Solutions
The Hague, Netherlands
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
String+NULL = NULL but not in SQL Server
Miscellaneous
Thread ID:
00217101
Message ID:
00217101
Views:
60
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.
Next
Reply
Map
View

Click here to load this message in the networking platform