SQL的同时操作性,select列表中的执行顺序


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
 SQL中的多个运算是同时进行计算的,即同时操作,all-at-once operation,与在select列表中的前后位置无关
如: update a
        set a.value1 = a.value2, a.value2 = a.value1  --同时发生,即时交换
        from tmpTable
由上知:1)select中的别名不能在同一select列表中使用。 如select max(id) mid, mid+1 from tmpTable 是错误的
             2)UPDATE t
                  SET t.c4 = convert(varchar(20),GETDATE(),120)
                  FROM tmp2 t
                  因执行是同时进行的,故t.c4得到的日期是相同的
             3)update a set a.value1 = 100 + (select max(c1) from tmpTable)    因执行是同时的,故最大值c1不会改变

4)应用:得到某一值,并将此值加1
                  update a set @value = value, value = value+1 from tmpTable