t1
Username
a
b
c
d
...
t2
Username NUN
a X
b Y
c Z
d M
...
把T1 中的username 替换为t2 中的nun
------解决方案--------------------
- SQL code
--> 测试数据:[t1]if object_id('[t1]') is not null drop table [t1]create table [t1]([Username] varchar(1))insert [t1]select 'a' union allselect 'b' union allselect 'c' union allselect 'd'--> 测试数据:[t2]if object_id('[t2]') is not null drop table [t2]create table [t2]([Username] varchar(1),[NUN] varchar(1))insert [t2]select 'a','X' union allselect 'b','Y' union allselect 'c','Z' union allselect 'd','M'update t1set [Username]=a.[NUN] from t2 a where t1.Username=a.Usernameselect * from t1/*UsernameXYZM*/