create table sjb (id int,sort varchar (20))
insert into sjb
select 1,'sql' union
select 2,'c++' union
select 3,'vb' union
select 4,'.net' union
select 6,'java'
select identity(int,1,1) as xh,* into #a from sjb
select identity(int,1,1) as xh,id,sort into #b from #a where xh%2=1
select identity(int,1,1) as xh,id,sort into #c from #a where xh%2<>1
select a.id,a.sort,b.id,b.sort
from
#b a full join #c b
on a.xh=b.xhdrop table #a
drop table #b
drop table #c
insert into sjb
select 1,'sql' union
select 2,'c++' union
select 3,'vb' union
select 4,'.net' union
select 6,'java'
select identity(int,1,1) as xh,* into #a from sjb
select identity(int,1,1) as xh,id,sort into #b from #a where xh%2=1
select identity(int,1,1) as xh,id,sort into #c from #a where xh%2<>1
select a.id,a.sort,b.id,b.sort
from
#b a full join #c b
on a.xh=b.xhdrop table #a
drop table #b
drop table #c
--- ---- -- ----
1 sql 2 c++
3 vb 4 .net
6 java NULL NULL
忘啦一点.ID是id int IDENTITY (1, 1) NOT NULL
当id为自增长时就不行啦.
无法使用 SELECT INTO 语句向表 '#a' 中添加标识列,该表中已有继承了标识属性的列 'id'。