Skip to content

Instantly share code, notes, and snippets.

@nisar1
Last active August 29, 2015 13:57
Show Gist options
  • Save nisar1/9595619 to your computer and use it in GitHub Desktop.
Save nisar1/9595619 to your computer and use it in GitHub Desktop.
transaction in sp mssql
create procedure uspContactPersonDeleteSingleItem
@id int
as
begin tran
delete from address where contactpersonid = @id;
if @@ERROR <> 0
begin
rollback tran
return -1
end
delete from emailaddress where contactpersonid = @id;
if @@ERROR <> 0
begin
rollback tran
return -1
end
delete from phonenumber where contactpersonid = @id ;
if @@ERROR <> 0
begin
rollback tran
return -1
end
delete from contactperson where id = @id ;
if @@ERROR <> 0
begin
rollback tran
return -1
end
commit tran
go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment