可以这样考虑:
定义一个变量a,赋值123
定义一个变量b,赋值456
把王刚的学号修改成变量b的值
把学号为456的修改成变量a的值
代码参考如下,未编译:
declare @a int set @a=123
declare @b int set @b=456
update abc
set xuehao=@b
where xingming='王刚'
update ab
set xuehao=@a
where xuehao=456
以下是更新的SQL语句,请采纳
UPDATE abc SET xuehao = if(xuehao='123','456','123') WHERE xuehao IN ('123','456');