Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

begin and commit transaction in stored procedure with multiple update statement

$
0
0

Hi have an SP with multiple Update statements. How to add begin, commit, and rollback into my SP.

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

 I want to apply commit / rollback for each of my update statements.. as per my business demands..



ShanmugaRaj



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>