write multple update statement in store procedure

Shambhu Rai 1,401 Reputation points
2023-02-02T16:49:08.2266667+00:00

Hi Expert,

How to write multipe update statement in store procedure

like update table set col=

update table set col2=

update table set co3=

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,297 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,734 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,414 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alberto Morillo 32,711 Reputation points MVP
    2023-02-02T17:17:30.65+00:00

    Here is an example:

    CREATE PROCEDURE prc_update (@table1_id INT, @table2_id INT, @table3_id INT, @new_value INT)
    AS
    BEGIN
            UPDATE  Table1
            SET     field1 = @new_value
            WHERE   id = @table1_id
    
            UPDATE  Table2
            SET     field2 = @new_value
            WHERE   id = @table2_id
    
            UPDATE  Table3
            SET     field3 = @new_value
            WHERE   id = @table3_id
    END
    
    0 comments No comments

0 additional answers

Sort by: Most helpful