将同一表中的一列的值更新到 SQL Server 中的另一列

2022-01-17 00:00:00 sql-update sql sql-server

我正在尝试用在 TYPE2 中找到的值覆盖在 TYPE1 中找到的值.

I'm trying to overwrite values that are found in TYPE1 with values that are found in TYPE2.

我写了这个 SQL 来尝试一下,但由于某种原因它没有更新:

I wrote this SQL to try it out, but for some reason it isn't updating:

select * from stuff

update stuff
set TYPE1 = TYPE2
where TYPE1 is null;

update stuff
set TYPE1 = TYPE2
where TYPE1 ='Blank';

http://www.sqlfiddle.com/#!3/a4733/17

我在 TYPE1 中的值没有更新的任何原因?

Any reason why my values in TYPE1 are not updating?

推荐答案

这对我有用

select * from stuff

update stuff
set TYPE1 = TYPE2
where TYPE1 is null;

update stuff
set TYPE1 = TYPE2
where TYPE1 ='Blank';

select * from stuff

相关文章