Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using MAX
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01390212
Message ID:
01390315
Vues:
47
>I think VFP will evaluate it twice. I'm not sure about SQL Server. What problem does it create for you if expression is evaluated more than once?
>Anyway, if you don't want it to be evaluated twice for sure, use derived table
>
>
>
>* VFP
>*SELECT IIF(FLD1 - FLD2 < 0, 0, FLD1 - FLD2) as NEWCOLUMN from MyTable
>SELECT IIF(days < 0, 0, days) as newcolumn ; 
>	FROM ( SELECT fld1-fld2 AS days FROM MyTable) dt1
>
>-- SQL Server
>*SELECT CASE WHEN FLD1 - FLD2 < 0 THEN 0 ELSE FLD1 - FLD2 END as NEWCOLUMN from MyTable
>SELECT (CASE WHEN days < 0 THEN 0 ELSE days END) as newcolumn  
>	FROM ( SELECT fld1-fld2 AS days FROM MyTable) dt1
>
>
>
>>>
>>
>>Do you know or do you think that SQL Server (and VFP too) evaluate the expression FLD1 - FLD2 twice or the engines are smart enough to only do it once? I am just curious if I should get the cursor with just the Days difference column and then process this cursor in VFP for negative values.

If fld1 and fld2 are datetime fields, then the second select statement (in SQL server) should be changed to use DATEDIFF function.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform