sqlserve更新

1、交换列

create table AAA_Test1
(
   A            int                    null,
   B            int                    null,
);

insert into AAA_Test1 values(1,2);

select * from AAA_Test1

update AAA_Test1 set A=B,B=A;

不需要临时变量就可以交换。

2、更新

update AAA_Test1 set A=B,B=null

delete AAA_Test1

insert into AAA_Test1 values(1,2);

update AAA_Test1 set B=null,A=B

更新结果都一样,和字段顺序无关,都是先更新表内部赋值,在更新外部赋值

posted @ 2020-11-19 17:19  江境纣州  阅读(18)  评论(0编辑  收藏  举报