SQL Server stored procedure parameter output

前端 未结 1 1467
清歌不尽
清歌不尽 2021-01-28 00:34

I have a stored procedure that I have scaled down considerably for the purpose of this question but in essence the issue I need assistance with is this.

If a row in tab

相关标签:
1条回答
  • 2021-01-28 00:52

    See the changes:

     -- this does not work for multiple IDs
      SELECT @IPV_ID_Found = @IPV_ID_Found + ',' + (CAST(@IPV_ID AS VARCHAR(500))) 
    

    then you will get a concatenated list of values, like 1,2,3,4,5

    BUT if you need to return a recordset, then you need not OUTPUT parameter, use the table variable instead:

    declare @IPV_ID_Found table(Item varchar(500))
    
    IF (@IPV_Status ='closed')
    BEGIN
    UPDATE TEST_TBL
     SET
        Status  = 'xyz',        
     WHERE                  
        ID      =  @IPV_ID 
    
      -- this works for one ID
      insert @IPV_ID_Found 
      VALUES (CAST(@IPV_ID AS VARCHAR(500)))    
    
      -- this does not work for multiple IDs
      INSERT @IPV_ID_Found 
      VALUES (CAST(@IPV_ID AS VARCHAR(500)))
    
      SELECT Item FROM @IPV_ID_Found                  
    END
    
    0 讨论(0)
提交回复
热议问题