We help IT Professionals succeed at work.

Loop with SCOPE_IDENTITY()

125 Views
Last Modified: 2017-04-25
Hello, I need to loop through table a and insert into table b get the SCOPE_IDENTITY() and use that to insert more data from table a into table c using the SCOPE_IDENTITY() .

table a is a flat table with company and worker information.
table b will become company table
table c will become worker table using company.Id(SCOPE_IDENTITY() ) as worker.companyId.

What is the best way to do this type of statement?
Comment
Watch Question

IT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Vitor MontalvãoIT Engineer
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Only possible answer for the question.