How can one iterate over stored procedure results from within another stored procedure…without cursors?

前端 未结 7 1872
半阙折子戏
半阙折子戏 2020-12-19 07:06

I\'m not sure if this is something I should do in T-SQL or not, and I\'m pretty sure using the word \'iterate\' was wrong in this context, since you should never iterate any

7条回答
  •  忘掉有多难
    2020-12-19 08:11

    Insert the results of the stored proc into a temporary table and join this to the table you want to update:

    INSERT INTO #WorkTable
    EXEC usp_WorkResults
    
    UPDATE DataTable
      SET Flag = Whatever
    FROM DataTable
    INNER JOIN #WorkTable
      ON DataTable.Ket = #WorkTable.Key
    

提交回复
热议问题