Stored procedure to update records with table-valued parameter RRS feed

  • Question

  • User2036269806 posted


    I want to create stored procedure to update records in table. Stored procedure have one parameter as table valued parameter, my parameter will contains (code , new price) , i want to access to table X and update the price based on code :

    something like this  :

    Loop throw my param table ()
    // here i wil current code and current price with two variables
    update X set price = @currentRowPrice where code = @currentRowCode

    I'm not familiar with stored procedure operations and loops, and i want your help guys,

    Thanks for help in advance,

    Tuesday, December 1, 2015 2:14 PM


  • User-808054615 posted


    I believe it is possible to update the table with a Update statement. Ex:

    update t
    set t.Price = p.NewPrice
    from MyTable as t
    inner join @MyTableValuedParameter as p
        on p.Code = t.Code

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 1, 2015 4:21 PM

All replies