• Register
0 votes

Problem :

My Stored Procedure is giving me following error
transaction count after execute indicates a mismatching number of begin and commit statements
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

This usually happens when one transaction is started and either it is not committed or it is not rolledback.

If the error comes in your stored procedure then it will lock the database tables as the transaction is not completed due to some runtime errors occuring in the absence of exception handling. So to avoid getting such errors you can use the Exception handling as shown below. 

SET NoCount ON
Begin Try 
        //Insert ,update queries    
End Try 
Begin Catch 
End Catch

Further Readings :


9 7 4
38,600 points

Related questions

0 votes
1 answer 161 views
Problem : I am facing following error with the below query in SQL Server 2012. An expression of non-boolean type specified in a context where a condition is expected, near 'RETURN'. SQL Query: CREATE FUNCTION [dbo].[GetMYPMResources](@UserResourceNo ... JOIN JobTask t ON t.JobTaskNo = m.JobTaskNo WHERE t.TaskManagerNo = @UserResourceNo OR t.AlternateTaskManagerNo = @UserResourceNo ) RETURN END
asked Dec 4, 2019 alecxe 7.5k points
0 votes
1 answer 4 views
Problem: How to select a partial of a table for exporting using SQL? How can I do that? Thanks
asked Mar 9 ummesalma 24.5k points
0 votes
1 answer 14 views
Problem: I am a beginner to sql. I have the 123MB sql file which I am trying to execute on my local PC. But I am facing the below error: Cannot execute script: Insufficient memory to continue the execution of the program. Whenever I click on Ctlr+E then it ... above error. I have tried to fix the above sql error with the help of online tutorials but they were not useful in fixing the error.
asked Aug 28, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 2 views
Problem: sql server management studio export to csv.
asked 1 day ago Dan phillip 4.7k points
0 votes
1 answer 1 view
1 view
Problem: Can you please explain why: select * from sys.dm_exec_sql_text (sql_handle)
asked Mar 22 ummesalma 24.5k points
1 vote
1 answer 160 views
Problem : My task is to send email with the file attachments also this attachment must come from the image type data field. If I try to run the below code in both the query window and the stored procedure but my email was not sent and in the query window I can only see ... = 1,     @query_no_truncate = 1; I need to send email but still unable to do so. I am looking for help in fixing the issue.
asked May 6, 2020 stewart 4k points
0 votes
1 answer 324 views
Problem : I don't understand why I am unable to insert this. I can't spot any problem. The error message is as below : Conversion failed when converting from a character string to uniqueidentifier. A GUIDs are the ... Server 2012 The columns are as below id        uniqueidentifier, myid      uniqueidentifier, friendid  uniqueidentifier, time1     datetime nullable, time2     datetime nullable
asked Jan 17, 2020 jwilliam 3.9k points
0 votes
1 answer 2 views
Problem: I tried to find The maximum number of digits after the decimal point in sql on the web but I did not get any fruitful information please help me.
asked Mar 30 zayed1 30.9k points
1 vote
1 answer 3 views
Problem: Please help me to solve it out : sql count number of orders per customer
asked Mar 17 MUHAMMAD MUNEEB 82.5k points