Can I get the results of a stored procedure into a cursor within another stored procedure in SQL

前端 未结 3 1544
慢半拍i
慢半拍i 2021-01-11 15:36

I\'m trying to put the results of a stored procedure into a cursor to use within the current procedure. I\'ve added my code below but I\'m not sure if this is possible or if

3条回答
  •  無奈伤痛
    2021-01-11 16:03

    You can do it like this:

    DECLARE @t TABLE (ID INT)
    INSERT INTO @t
    EXEC spGetUserIDs
    
    DECLARE cursorIDList CURSOR FOR
        SELECT * FROM @t
    OPEN cursorIDList
    
    FETCH NEXT FROM cursorIDList INTO @ID
    

提交回复
热议问题