Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Transaction Error

Author  Topic 

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-04-10 : 07:09:00
[code]
CREATE PROCEDURE Delete_Template
(
@ID BIGINT,
@Status BIT OUTPUT
)

BEGIN

BEGIN TRY
BEGIN TRANSACTION
DELETE A
OUTPUT
deleted.col1, deleted.col2

INTO audittable1(
col1, col2)
FROM maintable1
WHERE ID = @ID

IF @@ROWCOUNT > 0
BEGIN
DELETE A
OUTPUT
deleted.col1, deleted.col2
INTO audittable2
(col1, col2)
FROM maintable2 WHERE ID = @ID
END

COMMIT

SET @Status = 1


END TRY

BEGIN CATCH

ROLLBACK TRANSACTION
SET @Status = 0

END CATCH
END
[/code]
this procecure created successfully but
When I execute the procedure
[code]
DECLARE @Status AS BIT
EXEC Delete_Template 12, @Status OUT
SELECT @Status
[/code]

It is giving me error

Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 0, current count = 1.

Can anyone suggest me how to remove this error or any other way to handle this...Please


Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-04-10 : 08:13:48
Sorry I got the solution that was just a syntax error

I have not given alias name A in table...

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -