110,534
社区成员
发帖
与我相关
我的任务
分享
declare @a table
(
id int IDENTITY(1,1),
name varchar(20)
);
declare @detail table
(
id int,
detailId int
);
--插入过程执行
declare @temp table
(
tempid int
);
insert into @a --插入表a并输出id
OUTPUT inserted.id
INTO @temp
values('种类1')
insert into @detail --插入明细表 @detail
select (select top(1) tempid from @temp), 1 union all
select (select top(1) tempid from @temp), 2 union all
select (select top(1) tempid from @temp), 3
--测试明细表数据
select * from @detail