是否可以在一次选择中更新多个局部变量?
Is it possible to update more than one local variable in a single select?
类似于:
set
@variableOne = avg(someColumn),
@variableTwo = avg(otherColumn)
from tblTable
为像这个任务这样微不足道的事情做两个单独的选择操作似乎有点浪费:
It seems a bit wasteful to make two separate select operations for something as trivial as this task:
set @variableOne = ( select avg(someColumn) from tblTable )
set @variableTwo = ( select avg(otherColumn) from tblTable )
是这样的:
select @var1 = avg(someColumn), @var2 = avg(otherColumn)
from theTable
这篇关于T-SQL,在一次选择中更新多个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!