Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using CASE WHEN in JOIN?
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01535407
Message ID:
01535410
Views:
79
This message has been marked as the solution to the initial question of the thread.
The CASE is a function. The way you used it doesn't make any sense.
Try
ON (Table1.Fld1='' AND Table1.Fld2 = Table2.Fld2 )
   OR 
   (Table1.Fld1<>'' AND Table1.Fld1 = Table2.Fld1)
>
>I am trying to "translate" the VFP code that has IIF() in the JOIN into SQL Server systax. Here is what I have (but gives me error):
>
>
>select * from Table1 left join Table2 ON CASE WHEN LEN(RTRIM(Table1.Fld1))=0 THEN Table1.Fld2 = Table2.Fld2 
>  ELSE Table1.Fld1 = Table2.Fld1 END
>
>
>What am I missing? TIA
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform