create table #test (a int identity(1,1), b varchar(20), c varchar(20))
insert into #test (b,c) values ('bvju','hjab')
insert into #test (b,c) values ('bst','sdfkg')
......
insert into #test (b,c) values ('hdsj','kfsd')
我将如何插入得到了来自上面的INSERT语句填充到#sample
表(另一个表)的标识值(#test.a
)将标识列值从另一个表中插入表中?
create table #sample (d int identity(1,1), e int, f varchar(20))
insert into #sample(e,f) values (identity value from #test table, 'jkhjk')
insert into #sample(e,f) values (identity value from #test table, 'hfhfd')
......
insert into #sample(e,f) values (identity value from #test table, 'khyy')
可以在任何一个请解释我如何能实现这个较大的集的记录(数千记录)?
我们可以使用while
loop和scope_identity
?如果是这样,请解释我们该怎么做?
如果我从选择查询中插入#test,情况会是怎样?
INSERT INTO #TEST(B,C) 选择... ...从(几千条记录)
我将如何捕捉标识值并使用该值到另一个(#sample) 插入到#sample(E,F) 选择(身份从#TEST值),...从...(记录千元) - )
我已更新我的回答,以解决您删除的评论中的问题。 – canon