我有一个单列表,这是一个自动生成的标识
create table SingleIdTable (
id int identity(1,1) not null
)
我可以使用自动生成的 id 插入一行:
insert into SingleIdTable default values
我想插入许多行并使用输出语法来获取它们的 ID,例如:
insert into SingleIdTable
output inserted.Id into @TableOfIds
select (default values) from SomeOtherTable where Attribute is null
目的是使用自动生成的 idSingleIdTable
为每行插入一行,SomeOtherTable
其中为 null。Attribute
以上不起作用,但我该怎么做。我注意到,如果我的表不止一列,我可以这样做,但我不能选择空行,这是我真正想要做的。
我无法更改 的定义SomeOtherTable
。