Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 更新结果的t-sql输出_Sql Server 2008_Tsql - Fatal编程技术网

Sql server 2008 更新结果的t-sql输出

Sql server 2008 更新结果的t-sql输出,sql-server-2008,tsql,Sql Server 2008,Tsql,如何在此查询中打印此查询更新的行: 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

如何在此查询中打印此查询更新的行:

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

如果您使用的是SQL Server 2005及更高版本,则可以使用。

更新
表1.建议腿
设置
actualValue=(leg.actualprice*str.currentSize)
插入的输出。实际值--30

您使用的是哪个版本的SQL Server?就是这个版本,但输出在集合中。我一直有麻烦,直到我意识到插入的是表格。您可以执行类似“输出INSERTED.actualValue作为av,INSERTED.actualPrice作为ap,str.currentSize作为cs”的操作
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