SQL SERVER里的赋值机制闲聊
时间:2011-03-02 来源:peace
declare @date datetime
select @date=CurrentDate from users where ...
update users set LastDate = @date,CurrentDate=getdate() where ...
写到第三句基本上应该能想到连续赋值了,一般的计算机语言都是从右到左赋值的,多表达式的连续赋值计算优先级也是从右至左的,在SQL SERVER里也一样的,明白了这点,最佳的方式应该是这样写
update users set CurrentDate=getdate() , LastDate = CurrentDate where ...
算是啰嗦下~~
相关阅读 更多 +