Forums - C# Corner

Forum guidelines
narasiman rao

narasiman rao

  • 1.1k
  • 416
  • 440k

how to handle the error in transaction sql

Oct 6 2017 10:29 AM
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

Answers (1)