Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:10:29+00:00 2026-05-25T18:10:29+00:00

I am getting this error: Transaction count after EXECUTE indicates a mismatching number of

  • 0

I am getting this error:

Transaction count after EXECUTE indicates a mismatching number of
BEGIN and COMMIT statements. Previous count = 2, current count = 3.

But I don’t know enough about SQL Server to stop the error.

Here is my DROP PROCEDURE command:

--Specify database in which to uninstall procedure
USE SalesLogix_Dev
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'usp_matt_db_tasks')
            AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE usp_matt_db_tasks
GO

And here is the CREATE PROCEDURE:

--Specify database in which to install procedure
USE SalesLogix_Dev
GO

--Drop existing objects in order to guanrantee error-free install
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'usp_matt_db_tasks')
            AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE usp_matt_db_tasks
GO


CREATE PROCEDURE usp_matt_db_tasks
    -- Add the parameters for the stored procedure here

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    BEGIN TRANSACTION
INSERT INTO [SalesLogix_Dev].[sysdba].[LEAD] (
    CREATEUSER,
    CREATEDATE,
    MODIFYUSER,
    MODIFYDATE,
    FIRSTNAME,
    ACCOUNTMANAGERID,
    ASSIGNDATE,
    COMPANY,
    COMPANY_UC,
    EMAIL,
    DONOTSOLICIT,
    ISPRIMARY,
    LEADSOURCEID,
    SECCODEID,
    STATUS,
    LASTNAME,
    LASTNAME_UC,
    INDUSTRY,
    NOTES,
    HOMEPHONE) 
SELECT 
       ,'something'
       ,CURRENT_TIMESTAMP
       ,'something'    
       ,CURRENT_TIMESTAMP
       ,replace(firstname, '"', '')
       ,'something'
       ,CURRENT_TIMESTAMP
       ,replace(company, '"', '')
       ,replace(UPPER(company), '"', '')
       ,replace(email, '"', '')
       ,'1'
       ,'T'
       ,''
       ,'SYST00000001'
       ,'New'
       ,replace(lastname, '"', '')
       ,replace(UPPER(lastname), '"', '')
       ,replace(department, '"', '')
       ,replace(comments, '"', '')
       ,replace(phone, '"', '')

  FROM [SalesLogix_Dev].[sysdba].[CSVTemp]

update  [SalesLogix_Dev].[sysdba].[LEAD] set LEAD_ADDRESSID = 'Q' + LEADID where DONOTSOLICIT = 1

INSERT INTO [SalesLogix_Dev].[sysdba].[LEAD_ADDRESS] (
    LEAD_ADDRESSID,
    LEADID,
    CREATEUSER,
    CREATEDATE,
    MODIFYUSER,
    MODIFYDATE,
    ISMAILING,
    ISPRIMARY) 
SELECT 
      LEAD_ADDRESSID
     ,LEADID
     ,'something'
     ,CURRENT_TIMESTAMP
     ,'something'      
     ,CURRENT_TIMESTAMP
     ,'T'
     ,'T'

  FROM [SalesLogix_Dev].[sysdba].[LEAD] where DONOTSOLICIT = 1

  update  [SalesLogix_Dev].[sysdba].[LEAD] set DONOTSOLICIT = 0 where DONOTSOLICIT = 1
  DROP TABLE [SalesLogix_Dev].[sysdba].[CSVTemp]
  ROLLBACK  TRANSACTION
COMMIT TRANSACTION

END

And finally I execute as follows:

USE SalesLogix_Dev
GO

EXEC usp_matt_db_tasks;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:10:30+00:00Added an answer on May 25, 2026 at 6:10 pm

    To drop all the procedures with the name usp_matt_db_tasks you can run this query:

    DECLARE @sql NVARCHAR(MAX) = N'';
    
    SELECT @sql += 'DROP PROCEDURE ' 
        + SCHEMA_ID(name) + '.'
        + QUOTENAME(name) + ';'
        FROM sys.procedures WHERE name = 'usp_matt_db_tasks';
    
    EXEC sp_executesql @sql;
    

    You should rollback any transactions that are currently active, close your current window, then create procedure in a new query window:

    CREATE PROCEDURE dbo.usp_matt_db_tasks
    AS
    BEGIN
        SET NOCOUNT ON;
    
        BEGIN TRANSACTION;
    
        INSERT INTO [SalesLogix_Dev].[sysdba].[LEAD] 
        (
          CREATEUSER,
          ...
          HOMEPHONE
        ) 
        SELECT 
              ,'something'
              ...
              ,replace(phone, '"', '')
        FROM [SalesLogix_Dev].[sysdba].[CSVTemp];
    
        UPDATE [SalesLogix_Dev].[sysdba].[LEAD] 
          SET LEAD_ADDRESSID = 'Q' + LEADID 
          WHERE DONOTSOLICIT = 1;
    
        INSERT INTO [SalesLogix_Dev].[sysdba].[LEAD_ADDRESS] 
        (
          LEAD_ADDRESSID,
                  ...
          ISPRIMARY
        ) 
        SELECT 
          LEAD_ADDRESSID
                  ,...
          ,'T'
        FROM [SalesLogix_Dev].[sysdba].[LEAD]
        WHERE DONOTSOLICIT = 1;
    
        UPDATE [SalesLogix_Dev].[sysdba].[LEAD] 
          SET DONOTSOLICIT = 0 
          WHERE DONOTSOLICIT = 1;
    
        DROP TABLE [SalesLogix_Dev].[sysdba].[CSVTemp];
    
        COMMIT TRANSACTION;
    END
    GO
    

    Now when you call this procedure you should always use EXEC dbo.usp_matt_db_tasks; and you should probably consider adding some error handling so that you can properly rollback the transaction in case something goes wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting the following error: Transaction count after EXECUTE indicates a mismatching number of
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to
I am getting this error now that I hit version number 1.256.0: Error 4
I'm getting this error (Distributed transaction completed. Either enlist this session in a new
Out of the blue, i am getting this error when doing a number of
I am currently getting this error: System.Data.SqlClient.SqlException: New transaction is not allowed because there
I am getting this error: Network access for Distributed Transaction Manager (MSDTC) has been
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.