troubleshooting Question

Loop with SCOPE_IDENTITY()

Avatar of Scott Baldridge
Scott Baldridge asked on
Microsoft SQL Server
2 Comments1 Solution131 ViewsLast Modified:
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?
ASKER CERTIFIED SOLUTION
Vitor Montalvão
IT Engineer
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros