Reputation: 3905
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.
Upvotes: 1
Views: 2070
Reputation: 238086
That's a pretty straightforward insert:
insert Table2
(c1, c2, c3, c4)
select col1, col2, col3, @var
from Table1
Upvotes: 2
Reputation: 838216
Try this:
INSERT INTO Table2 (c1,c2,c3,c4)
SELECT col1, col2, col3, @var FROM table1
Upvotes: 2