1

I want to insert into table single record in one shot with values coming from QUERY + VARIABLE.

E.g. Insert into Table2(c1,c2,c3,c4)

c1,c2,c3 are coming from select col1,col2,col3 from Table1 c4 is coming from variable @var

As the volume of data is huge, I can not have one insert and second update.

Thanks in advance.

2 Answers 2

2

That's a pretty straightforward insert:

insert  Table2
        (c1, c2, c3, c4)
select  col1, col2, col3, @var
from    Table1
Sign up to request clarification or add additional context in comments.

Comments

2

Try this:

INSERT INTO Table2 (c1,c2,c3,c4) 
SELECT col1, col2, col3, @var FROM table1

Comments

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.