Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update from Select
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01673282
Message ID:
01673312
Vues:
42
Sorry for another question.

In the UPDATE command, the order of evaluation is always as it is in the statement, left to right?
Let me show you and example:
update t1 set @Qty2Use = case when t1.qty_left >= @QtyUseRemain then @QtyUseRemain else t1.qty_left end,  
t1.qty_left = t1.qty_left - @Qty2Use, 
@QtyUseRemain = @QtyUseRemain - @Qty2Use,
t1.rec_id = case when t1.qty_left > 0 then '1' else '2' end,
@QtyLeft = t1.qty_left, 
....
In my case, after the first iteration the value of the variable @QtyLeft remains greater than 0 even though the quantity should be reduced.
So, my question is, is the line
t1.qty_left = t1.qty_left - @Qty2Use, 
always executed before the line:
@QtyLeft = t1.qty_left, 
Or it is random?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform