简体   繁体   中英

Run stored procedure for multiple rows & record success/failure?

I have the below table which gets loaded into my DB each night (this usually contains more rows, but I have just included 2 for example).

I then have a stored procedure called [dbo].[StitchUsernames] which accepts the UserID as a parameter. This stored procedure takes the UserID and updates another table to say that the UserID has been successfully imported.

What I am trying to achieve have the stored procedure run for every row in the table & record the outcome of the stored procedure run (success/fail) in the StitchResult table.

What would be the best way to achieve this? So for the below example, I would want it to run for UserID = 455 and then update StitchResult to success/error. Then it would move on to 22 and do the same.. until all rows have been worked through.

  UserID           Username         StitchResult
  ----------------------------------------------
   455              Peter.S            NULL
   22               Maureen.T          NULL

Appreciate any advice? I have tried looking at cursors but was reading these can cause performance issues?

I have been able to achieve this using the below method in azure data factory.. hopefully it is useful to someone else!

https://helicaltech.com/lookup-foreach-activity-azure-data-factory/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM