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,438
  • 68
  • 55
  • 126
MrFox
  • 4,572
  • 4
  • 42
  • 76

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,472
  • 1
  • 14
  • 24