27,580
社区成员
发帖
与我相关
我的任务
分享
declare @maxid int
select @maxid = max(id) from c
select identity(int,1,1) as id, a或b的字段 into #t from table1 a,table2 b where 条件..
update #t set id=id+@maxid
insert into C(id,a,b,c) select id,其它三个字段 from #t
drop table #t
insert into C(id,a,b,c)
select a,b,c from table1 a,table2 b where 条件..
insert into C(id,a,b,c)
select a类型数据,b类型数据,c类型数据 from table1 a,table2 b where 条件..
declare @tb table (id int,name varchar(10))
insert into @tb select 2,'a'
insert into @tb select 5,'b'
insert into @tb select 7,'c'
insert into @tb select 10,'d'
select row_number() over (order by id)+(select max(id) from @tb),* from @tb
是这列吗? id name
11 2 a
12 5 b
13 7 c
14 10 d