I have this store procedure;
USE [DataBase]
GO
/****** Object: StoredProcedure [dbo].[DeleteAll] Script Date: 05/09/2011 00:18:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DeleteAll]
@theID uniqueidentifier
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
BEGIN TRANSACTION
BEGIN TRY
DELETE FROM Table1
WHERE ID = @theID
DELETE FROM Table2
WHERE ID = @theID
DELETE FROM Table3
WHERE ID = @theID
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION
END
END CATCH;
IF @@TRANCOUNT > 0
BEGIN
COMMIT TRANSACTION
END
END
It’s possible to return an integer depending on the result??
For example: 1 for success, 2 for the catch.
Thanks in advance!
Edgar.
Yes, it is possible.
Use the
RETURNstatement and check the return value in your client code.