0

I've found ways to pass an array to a stored procedure and ways to insert a table into another table. But I want to insert my array in a table as column2 with one other value I have as the value for column1:

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

I tried inserting the array into column2 first and then updating column1 to be the one value. But that didn't work and would be insanely expensive anyway.

Is there a reasonable way to do this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
MrFox
  • 4,852
  • 7
  • 45
  • 81

1 Answers1

4

If I'm understanding you correctly, then all you need is to get rid of the VALUES, like so:

INSERT INTO Table1 (column1, column2)
SELECT @value, column2 from @otherTable;
Joe Farrell
  • 3,502
  • 1
  • 15
  • 25