Reputation: 1368
I have a temptable in my query which could have certain records like
Id Name
34 one
35 two
65 five
Now for each row in temp table, I want to insert a new row in history table
So the history table now would have 3 new records
Id created date updatedby
34 createdDate
35 createdDate
65 createdDate
Upvotes: 2
Views: 15879
Reputation: 39527
You can insert using select.
Something like this:
insert into history (id, created_date, updatedBy)
select id, getdate(), 'add person here??'
from #temptable;
The above require the updatedBy to be supplied in the select query.
If you want current user, you could use SUSER_NAME()
Upvotes: 8