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