日期:2014-05-17 浏览次数:20583 次
--drop table t
create table t(CUS_ID int,CUS_NAME varchar(10),CUS_MOBILE varchar(20))
insert into t
select 101,NULL,'1311234567' union all
select 101,NULL,'1321234567' union all
select 101,'张三','1331234567' union all
select 102,NULL,'1891234567' union all
select 102,'李四','1381234567' union all
select 103,'王五','1380000000' union all
select 103,NULL,'1361234567'
go
update t
set CUS_NAME = tt.CUS_NAME
from t
inner join t tt
on t.CUS_ID = tt.CUS_ID
where t.CUS_NAME is null and tt.CUS_NAME is not null
select * from t
/*
CUS_ID CUS_NAME CUS_MOBILE
101 张三 1311234567
101 张三 1321234567
101 张三 1331234567
102 李四 1891234567
102 李四 1381234567
103 王五 1380000000
103 王五 1361234567
*/