Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

t-sql output of updated results

How can I print the rows updated by this query in this query:

update
    Table1.RecommendationLeg 
set 
    actualValue = ( leg.actualprice * str.currentSize)
from
    Table1.RecommendationLeg leg  
    inner join Recommendation str 
        on leg.partofId = str.id
where 
    leg.actualValue = 0 
    and datediff( n, timeOf, CURRENT_TIMESTAMP) > 30
like image 752
PhilBrown Avatar asked Jan 07 '11 17:01

PhilBrown


1 Answers

update
    Table1.RecommendationLeg 
set 
    actualValue = ( leg.actualprice * str.currentSize)
OUTPUT INSERTED.actualValue -- <-- this. Edit, after SET not UPDATE. Oops. Sorry.
from
    Table1.RecommendationLeg leg  
    inner join Recommendation str 
        on leg.partofId = str.id
where 
    leg.actualValue = 0 
    and datediff( n, timeOf, CURRENT_TIMESTAMP) > 30
like image 86
gbn Avatar answered Oct 17 '22 01:10

gbn