日期:2014-05-17 浏览次数:20504 次
select '1','PP,*' union all
select '1','*' union all
select '1','PP' union all
select '2','uu,*' union all
select '2','uu' union all
select '2','*' union all
select '3','' union all
select '3','*'
select '1','PP,*'
select '2','UU,*'
select '3','*'
--select '1' id,'PP,*'NAME INTO #A
-- union all
--select '1','*' union all
--select '1','PP' union all
--select '2','uu,*' union all
--select '2','uu' union all
--select '2','*' union all
--select '3','' union all
--select '3','*'
--select '1' id,'PP,*' NAME INTO #B
--union all
--select '2','UU,*'
--union all
--select '3','*'
SELECT * FROM #a
SELECT * FROM #b
UPDATE #a
SET #a.name=#b.name
FROM #b
WHERE #a.id=#b.id
/*
id NAME
---- ----
1 PP,*
1 PP,*
1 PP,*
2 UU,*
2 UU,*
2 UU,*
3 *
3 *
*/
select '1' id,'PP,*' descr INTO #a union all
select '1','*' union all
select '1','PP' union all
select '2','uu,*' union all
select '2','uu' union all
select '2','*' union all
select '3','' union all
select '3','*'
select '1' id,'PP,*' descr INTO #b union all
select '2','UU,*' union all
select '3','*'
UPDATE a SET descr=b.descr
from #a a
JOIN #b b ON a.id=b.id
SELECT * FROM #a
create table a(id varchar(10),descr varchar(20))
insert into a
select '1' id,'PP,*' union all
select '1','*' union all
select '1','PP' union all
select '2','uu,*' union all
select '2','uu' union all
select '2','*' union all
select '3','' union all
select '3','*'
creat