将数组传递给 sql 并用一个值将其插入 link table

Pass array on to sql and insert it in link table with one value

我发现 ways to pass an array to a stored procedure and ways 可以将 table 插入另一个 table。但是我想将我的数组作为 column2 插入到 table 中,并将另一个值作为 column1 的值:

INSERT INTO Table1 (column1, column2)  
VALUES (SELECT @value, column2 from @otherTable)

我尝试先将数组插入 column2,然后将 column1 更新为唯一值。但这没有用,而且无论如何都会非常昂贵。

有合理的方法吗?

如果我对你的理解是正确的,那么你只需要摆脱 VALUES,就像这样:

INSERT INTO Table1 (column1, column2)
SELECT @value, column2 from @otherTable;