Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Logical columns in SQL Server
Message
 
 
À
30/07/2001 15:17:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00537398
Message ID:
00537405
Vues:
17
This message has been marked as the solution to the initial question of the thread.
You can use CASE in SQL as you use IIF in foxpro
SELECT CLIENTFIRST, CLIENTLAST,    
      CASE WHEN STAFF_KEY=12 THEN 1
           ELSE 0
      END AS MYCLI FROM CLIENTS
>In SQL passthrough queries, is there a way other than a brute force double query joined with UNION ALL to return the results of a logical exression as a column? This syntax is not accepted by MS SQL Server:
>
>SELECT CLIENTFIRST, CLIENTLAST, STAFF_KEY=12 AS MYCLI FROM CLIENTS
>
>the trick of
>
>SELECT CLIENTFIRST, CLIENTLAST, 1 AS MYCLI FROM CLIENTS WHERE STAFF_KEY=12
>UNION ALL
>SELECT CLIENTFIRST, CLIENTLAST, O AS MYCLI FROM CLIENTS WHERE STAFF_KEY<>12
>
>gets very unwieldy when you want multiple logical columns.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform