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?

0

1 Answer 1

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;
Sign up to request clarification or add additional context in comments.

2 Comments

Nice Joe. I was just about to post the same thing. You beat me by a few seconds. :D
Beat me as well... Note to self: answer first, edit later. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.