Create Proc TranTest
AS
BEGIN TRAN
INSERT INTO [authors]([au_id],
[au_lname],
[au_fname],
[phone],
[contract])
VALUES ('172-32-1176',
'Gates',
'Bill',
'800-BUY-MSFT',
1)
-- First Update query
UPDATE authors
SET au_fname = 'Johnzzz'
WHERE au_id = '172'
-- second Update query
UPDATE authors
SET au_fname = 'Johnzzz'
WHERE au_id = '175'
--third Update query
UPDATE authors
SET au_fname = 'Johnzzz'
WHERE au_id = '178'
COMMIT TRAN
GO
in the above i written three update statement, if suppose in the second update statment gets error, whether the first update statement record gets updated.
for that how to handle using transact sql
How to handle the error in transaction sql
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Ankit SharmaRank #141 · 16.1K reputationPosted Oct 6, 2017, 8:05 AM EDT