Reputation: 55
need help on copying while updating multiple rows of data from one table to another table.
After copying and inserting those data from the old table to the new table, i would like to update the old table rows that was copied.
For example, OldTable has 30 rows of data. I want to copy 10 rows of data to NewTable and I want to update the column of the 10 rows in the OldTable to 'Copied'.
Question would be how does the old table know which rows had been copied to the new table so that I could update it?
Thanks in advance!
Upvotes: 0
Views: 489
Reputation: 294287
Use the OUTPUT clause:
update top(10) OldTable
set column = 'Copied'
output deleted.fields into NewTable.fields
where condition;
Upvotes: 2