web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested answer

Cannot execute a stored procedure.\nThe SQL database has issued an error.

(2) ShareShare
ReportReport
Posted on by 8
after restoring UAT Database on Dev machine.
I got following error 
 
Cannot execute a stored procedure.\nThe SQL database has issued an error. Object Server Azure: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Procedure or function \ngetNumInternalWithNoBlocking has too many arguments specified.
 
compiled, build sync all done.
When ever going to create new numbersequence. this error appear.
 
Regards
Ali Raza
I have the same question (5)
  • Sohaib Cheema Profile Picture
    49,066 User Group Leader on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    Hi,
    Is the version number of Dynamics the same on both the source and the destination?
  • CU04051204-0 Profile Picture
    8 on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    Cheema Saab Source and destination both are same version. 
     
    Source :
     
     
     
    Destination :
     
     
     
     
     
     
  • Sohaib Cheema Profile Picture
    49,066 User Group Leader on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    Hi,
     
    I have checked the sys.all_objects on the SQL server database for Dynamics and I do not find any single object named as ngetNumInternalWithNoBlocking
     
    That again leaves us with few questions.1
    1) Do you have any customized sql store procure or function named ngetNumInternalWithNoBlocking ?
    2) Has this DEV machine been there for a few months and you have not updated in's SQL Server?
     
    One thing that you can attempt and it may work.
    1) take a backup of database from DEV machine.
    2) go into SQL Server and take the backup (create script) fro the object named ngetNumInternalWithNoBlocking
    3) drop the object named ngetNumInternalWithNoBlocking
    4) now restore the database from UAT to DEV
     
    the error message is not happy about the difference of the signature for the store procedure (or function)
     
     
  • André Arnaud de Calavon Profile Picture
    300,021 Super User 2025 Season 2 on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    The stored procedure is dbo.getNumInternalWithNoBlocking. This is standard and not a custom procedure. 
     
    \n is usually a line break. 
     
    I have not seen this error before after a copy of the database. You can compare the stored procedure with another in a different database/environment. 
    Maybe it is related to permissions? If so, check the permissions set for the stored procedure.
  • Martin Dráb Profile Picture
    236,927 Most Valuable Professional on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    Two people reported the same problem in the insider forum. One said that "installing latest KB articles helped".
    Try applying the latest platform update.
  • Suggested answer
    Mauricio Minoru Profile Picture
    8 on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.

    Hello everyone,

    I had the same issue and I believe I've found a potential solution for this issue.

    The fix involves replacing the current [dbo].[getNumInternalWithNoBlocking] stored procedure with the following version. You will need to drop the existing procedure and then create this one, I took this procedure from a Contoso database in version 10.0.45. I tested it here and it worked correctly:

    CREATE PROCEDURE [dbo].[getNumInternalWithNoBlocking]
        @numberid bigint,
        @globalTransId bigint,
        @UserId nvarchar(20),
        @sessionid int,
        @sessionLoginDateTime datetime,
        @deploymentNumberId bigint,
        @Partition bigint,
        @considerAssignmentCount int =0,
        @nextValue bigint output
    AS
    BEGIN
         
    	-- hesitant to add one more SP as artifact rather than duplicate a code; 
        -- using SysFlighting rather than using ECSFlighting - as it is simple to retire a feature flight - instead of passing through code
       
        -- not making this mandatory - from rollout - these fixes are needed for edge cases - we more often do not have diff partition if
        -- need only for on-prem to cloud upgrade - -enableNumSeqConcurrentIssueInPrePopulateFix - need when prefetch value is high
        -- -enableCNSEnableOrderByInPickUpClause - this is needed only for wierd customer ask - as CONTINUOUS KEYWORD IS MISNOMER (it is no gap not sequential)
        -- documented - still it keeps coming!
       
        DECLARE @enableNumSeqConcurrentIssueInPrePopulateFix int =0; 
    	DECLARE @enableCNSEnableOrderByInPickUpClause int =0; 
    	DECLARE @PerformPartitionCheckFlag int = 0; 
        DECLARE @extended int;
        DECLARE @continuous int;
        DECLARE @fetchAheadQty bigint;
        DECLARE @DefaultMaxAssignmentConfigCount int = 5;
        DECLARE @MaxAssignmentConfigCount int = @DefaultMaxAssignmentConfigCount;
    	DECLARE @NextValueTable TABLE (NextValue BIGINT);
    
      
         --whether we should start take a lock on Number Sequence table while populating record in pre-populate
        DECLARE @EnableNumSeqConcurrentIssueInPrePopulateFlightName nvarchar(512) = 'EnableNumSeqConcurrentIssueInPrePopulateFix';  
    	DECLARE @EnableCNSEnableOrderByInPickUpClauseFlightName nvarchar(512) = 'EnableCNSEnableOrderByInPickUpClause';  
    	DECLARE @PerformPartitionCheckFlightName nvarchar(512) = 'PerformPartitionCheckInNumberSequence';
    
    	-- just assign zero if it is null
    	IF @considerAssignmentCount IS NULL
    		SET @considerAssignmentCount = 0;
    
    	WITH FlightStatus AS (
    		SELECT FlightName, Enabled
    		FROM dbo.SysFlighting WITH (NOLOCK)
    		WHERE FlightName IN (
    			@EnableNumSeqConcurrentIssueInPrePopulateFlightName,
    			@EnableCNSEnableOrderByInPickUpClauseFlightName,
    			@PerformPartitionCheckFlightName
    		)
    	)
    	SELECT
    		@enableNumSeqConcurrentIssueInPrePopulateFix = MAX(CASE WHEN FlightName = @EnableNumSeqConcurrentIssueInPrePopulateFlightName THEN Enabled ELSE 0 END),
    		@enableCNSEnableOrderByInPickUpClause = MAX(CASE WHEN FlightName = @EnableCNSEnableOrderByInPickUpClauseFlightName THEN Enabled ELSE 0 END),
    		@PerformPartitionCheckFlag = MAX(CASE WHEN FlightName = @PerformPartitionCheckFlightName THEN Enabled ELSE 0 END)
    	FROM FlightStatus;
    
    	-- better to explicit it to 0 ; incase no record found
    	SET @enableNumSeqConcurrentIssueInPrePopulateFix = ISNULL(@enableNumSeqConcurrentIssueInPrePopulateFix, 0);
    	SET @enableCNSEnableOrderByInPickUpClause = ISNULL(@enableCNSEnableOrderByInPickUpClause, 0);
    	SET	@PerformPartitionCheckFlag = ISNULL(@PerformPartitionCheckFlag, 0);
    
    	SELECT TOP 1 @continuous = [CONTINUOUS], @extended = [EXTENDED], @fetchAheadQty = [FETCHAHEADQTY] FROM [dbo].[NUMBERSEQUENCETABLE] WITH (NOLOCK) WHERE [NUMBERSEQUENCETABLE].[RECID] = @numberid;
            
        DECLARE @MaxAssignmentConfigCountName varchar(256) = 'VOLATILE_NUMSEQ_CNS_MAXASSIGNMENTCOUNT';
        SELECT TOP 1 @MaxAssignmentConfigCount = [value] from [dbo].sysGlobalConfiguration (nolock) where [NAME] =@MaxAssignmentConfigCountName;
    
        if @MaxAssignmentConfigCount IS NULL or @MaxAssignmentConfigCount <= 0
        BEGIN
            SET @MaxAssignmentConfigCount = @DefaultMaxAssignmentConfigCount;
        END
    	
    	--Get the next available free number from NSL table.  
    	if  @enableCNSEnableOrderByInPickUpClause > 0
    	BEGIN			
    		;WITH TargetRow AS (
    			SELECT TOP(1) * FROM NUMBERSEQUENCELIST WITH (ROWLOCK, READPAST) 
    			WHERE 
    			NUMBERSEQUENCEID = @numberid AND STATUS = 0 
    			and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition) and 
    			(@considerAssignmentCount =0 OR (ASSIGNMENTCOUNT IS NULL) or (ASSIGNMENTCOUNT <  @MaxAssignmentConfigCount))
    			ORDER BY RecId
    		)
    		UPDATE TargetRow
    		SET 
    			STATUS = 4, TRANSID = @globalTransId,MODIFIEDTRANSACTIONID = @globalTransId, USERID = @UserId,MODIFIEDBY = @UserId,
    			SESSIONID = @sessionid,SESSIONLOGINDATETIME = @sessionLoginDateTime, 
    			ASSIGNMENTCOUNT = ISNULL(ASSIGNMENTCOUNT, 0) + 1
    		OUTPUT 
    			CASE WHEN @extended != 0 THEN INSERTED.NEXTREC64 ELSE INSERTED.NEXTREC END
    		INTO @NextValueTable;
    
    		SELECT @nextValue = NextValue FROM @NextValueTable;
    		select @nextValue as DidWeFindValue;
    	END
        ELSE
    	BEGIN
    			UPDATE top(1) [NUMBERSEQUENCELIST] with (rowlock, readpast)
    			SET
                    STATUS=4, TRANSID=@globalTransId, MODIFIEDTRANSACTIONID=@globalTransId, USERID=@UserId,
                    MODIFIEDBY=@UserId, SESSIONID=@sessionid, SESSIONLOGINDATETIME=@sessionLoginDateTime,
                    @nextValue= CASE WHEN @extended != 0 THEN [NEXTREC64] ELSE [NEXTREC] END ,
                    ASSIGNMENTCOUNT = ISNULL(ASSIGNMENTCOUNT, 0) + 1
    			WHERE
                NUMBERSEQUENCEID= @numberid and STATUS = 0 and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition) and 
    			(@considerAssignmentCount =0 OR (ASSIGNMENTCOUNT IS NULL) or (ASSIGNMENTCOUNT <  @MaxAssignmentConfigCount))
    	END
    	
      
        IF @nextValue = 0 or @nextValue is null
        BEGIN
            -- if the free numbe is not present in the NSL table, generate the new numbers and then return it.
            exec prePopulateNumbers @numberseqid=@numberid, @maxquantity=@fetchAheadQty, @enableNumSeqConcurrentIssueInPrePopulateFix = @enableNumSeqConcurrentIssueInPrePopulateFix;
      
    		if @enableCNSEnableOrderByInPickUpClause > 0
    		BEGIN
    				;WITH TargetRow AS (
    					SELECT TOP(1) * FROM NUMBERSEQUENCELIST WITH (ROWLOCK, READPAST) 
    					WHERE 
    					NUMBERSEQUENCEID = @numberid AND STATUS = 0 
    					and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition) and 
    					(@considerAssignmentCount =0 OR (ASSIGNMENTCOUNT IS NULL) or (ASSIGNMENTCOUNT <  @MaxAssignmentConfigCount))
    					ORDER BY RecId
    				)
    				UPDATE TargetRow
    				SET 
    					STATUS = 4, TRANSID = @globalTransId,MODIFIEDTRANSACTIONID = @globalTransId, USERID = @UserId,MODIFIEDBY = @UserId,
    					SESSIONID = @sessionid,SESSIONLOGINDATETIME = @sessionLoginDateTime, 
    					ASSIGNMENTCOUNT = ISNULL(ASSIGNMENTCOUNT, 0) + 1
    				OUTPUT 
    					CASE WHEN @extended != 0 THEN INSERTED.NEXTREC64 ELSE INSERTED.NEXTREC END
    				INTO @NextValueTable;
    
    				SELECT @nextValue = NextValue FROM @NextValueTable;
    		END
    		ELSE
    		BEGIN		   
    		    UPDATE top(1) [NUMBERSEQUENCELIST] with (rowlock, readpast)
    			SET
                    STATUS=4, TRANSID=@globalTransId, MODIFIEDTRANSACTIONID=@globalTransId, USERID=@UserId,
                    MODIFIEDBY=@UserId, SESSIONID=@sessionid, SESSIONLOGINDATETIME=@sessionLoginDateTime,
                    @nextValue= CASE WHEN @extended != 0 THEN [NEXTREC64] ELSE [NEXTREC] END ,
                    ASSIGNMENTCOUNT = ISNULL(ASSIGNMENTCOUNT, 0) + 1
    			WHERE
                    NUMBERSEQUENCEID= @numberid and STATUS = 0 and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition) and 
    				(@considerAssignmentCount =0 OR (ASSIGNMENTCOUNT IS NULL) or (ASSIGNMENTCOUNT <  @MaxAssignmentConfigCount));
    		END        
        END
        select @nextValue;
    END
     
  • Suggested answer
    Sad Sadhish Profile Picture
    4 on at
    Cannot execute a stored procedure.\nThe SQL database has issued an error.
    @CU04051204-0 

    I was also facing the same issue while using the stored procedure. The issue is now resolved after making a change.

    Please try altering the stored procedure [dbo].[getNumInternalWithNoBlocking] and check if it resolves the problem on your end as well.

    USE [AxDB]
    GO
    /****** Object:  StoredProcedure [dbo].[getNumInternalWithNoBlocking]    Script Date: 10/29/2025 9:52:28 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[getNumInternalWithNoBlocking]
        @numberid bigint,
        @globalTransId bigint,
        @UserId nvarchar(20),
        @sessionid int,
        @sessionLoginDateTime datetime,
        @deploymentNumberId bigint,
        @Partition bigint,
        @nextValue bigint output
    AS
    BEGIN
         
        -- hesitant to add one more SP as artifact rather than duplicate a code; 
        -- using SysFlighting rather than using ECSFlighting - as it is simple to retire a feature flight - instead of passing through code
       
        -- not making this mandatory - from rollout - these fixes are needed for edge cases - we more often do not have diff partition if
        -- need only for on-prem to cloud upgrade - -enableNumSeqConcurrentIssueInPrePopulateFix - need when prefetch value is high
        -- -enableCNSEnableOrderByInPickUpClause - this is needed only for wierd customer ask - as CONTINUOUS KEYWORD IS MISNOMER (it is no gap not sequential)
        -- documented - still it keeps coming!
       
        DECLARE @enableNumSeqConcurrentIssueInPrePopulateFix int =0; 
        DECLARE @enableCNSEnableOrderByInPickUpClause int =0; 
        DECLARE @PerformPartitionCheckFlag int = 0; 
        DECLARE @extended int;
        DECLARE @continuous int;
        DECLARE @fetchAheadQty bigint;
        DECLARE @DefaultMaxAssignmentConfigCount int = 5;
        DECLARE @MaxAssignmentConfigCount int = @DefaultMaxAssignmentConfigCount;
        DECLARE @NextValueTable TABLE (NextValue BIGINT);
      
         --whether we should start take a lock on Number Sequence table while populating record in pre-populate
        DECLARE @EnableNumSeqConcurrentIssueInPrePopulateFlightName nvarchar(512) = 'EnableNumSeqConcurrentIssueInPrePopulateFix';  
        DECLARE @EnableCNSEnableOrderByInPickUpClauseFlightName nvarchar(512) = 'EnableCNSEnableOrderByInPickUpClause';  
        DECLARE @PerformPartitionCheckFlightName nvarchar(512) = 'PerformPartitionCheckInNumberSequence';
        WITH FlightStatus AS (
            SELECT FlightName, Enabled
            FROM dbo.SysFlighting WITH (NOLOCK)
            WHERE FlightName IN (
                @EnableNumSeqConcurrentIssueInPrePopulateFlightName,
                @EnableCNSEnableOrderByInPickUpClauseFlightName,
                @PerformPartitionCheckFlightName
            )
        )
        SELECT
            @enableNumSeqConcurrentIssueInPrePopulateFix = MAX(CASE WHEN FlightName = @EnableNumSeqConcurrentIssueInPrePopulateFlightName THEN Enabled ELSE 0 END),
            @enableCNSEnableOrderByInPickUpClause = MAX(CASE WHEN FlightName = @EnableCNSEnableOrderByInPickUpClauseFlightName THEN Enabled ELSE 0 END),
            @PerformPartitionCheckFlag = MAX(CASE WHEN FlightName = @PerformPartitionCheckFlightName THEN Enabled ELSE 0 END)
        FROM FlightStatus;
        -- better to explicit it to 0 ; incase no record found
        SET @enableNumSeqConcurrentIssueInPrePopulateFix = ISNULL(@enableNumSeqConcurrentIssueInPrePopulateFix, 0);
        SET @enableCNSEnableOrderByInPickUpClause = ISNULL(@enableCNSEnableOrderByInPickUpClause, 0);
        SET    @PerformPartitionCheckFlag = ISNULL(@PerformPartitionCheckFlag, 0);
        SELECT TOP 1 @continuous = [CONTINUOUS], @extended = [EXTENDED], @fetchAheadQty = [FETCHAHEADQTY] FROM [dbo].[NUMBERSEQUENCETABLE] WITH (NOLOCK) WHERE [NUMBERSEQUENCETABLE].[RECID] = @numberid;
            
        DECLARE @MaxAssignmentConfigCountName varchar(256) = 'VOLATILE_NUMSEQ_CNS_MAXASSIGNMENTCOUNT';
        SELECT TOP 1 @MaxAssignmentConfigCount = [value] from [dbo].sysGlobalConfiguration (nolock) where [NAME] =@MaxAssignmentConfigCountName;
        if @MaxAssignmentConfigCount IS NULL or @MaxAssignmentConfigCount <= 0
        BEGIN
            SET @MaxAssignmentConfigCount = @DefaultMaxAssignmentConfigCount;
        END
        
        --Get the next available free number from NSL table.  
        if  @enableCNSEnableOrderByInPickUpClause > 0
        BEGIN            
            ;WITH TargetRow AS (
                SELECT TOP(1) * FROM NUMBERSEQUENCELIST WITH (ROWLOCK, READPAST) 
                WHERE 
                NUMBERSEQUENCEID = @numberid AND STATUS = 0 
                and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition)
                ORDER BY RecId
            )
            UPDATE TargetRow
            SET 
                STATUS = 4, TRANSID = @globalTransId,MODIFIEDTRANSACTIONID = @globalTransId, USERID = @UserId,MODIFIEDBY = @UserId,
                SESSIONID = @sessionid,SESSIONLOGINDATETIME = @sessionLoginDateTime
            OUTPUT 
                CASE WHEN @extended != 0 THEN INSERTED.NEXTREC64 ELSE INSERTED.NEXTREC END
            INTO @NextValueTable;
            SELECT @nextValue = NextValue FROM @NextValueTable;
            select @nextValue as DidWeFindValue;
        END
        ELSE
        BEGIN
                UPDATE top(1) [NUMBERSEQUENCELIST] with (rowlock, readpast)
                SET
                    STATUS=4, TRANSID=@globalTransId, MODIFIEDTRANSACTIONID=@globalTransId, USERID=@UserId,
                    MODIFIEDBY=@UserId, SESSIONID=@sessionid, SESSIONLOGINDATETIME=@sessionLoginDateTime,
                    @nextValue= CASE WHEN @extended != 0 THEN [NEXTREC64] ELSE [NEXTREC] END
                WHERE
                NUMBERSEQUENCEID= @numberid and STATUS = 0 and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition)
        END
        
      
        IF @nextValue = 0 or @nextValue is null
        BEGIN
            -- if the free numbe is not present in the NSL table, generate the new numbers and then return it.
            exec prePopulateNumbers @numberseqid=@numberid, @maxquantity=@fetchAheadQty, @enableNumSeqConcurrentIssueInPrePopulateFix = @enableNumSeqConcurrentIssueInPrePopulateFix;
      
            if @enableCNSEnableOrderByInPickUpClause > 0
            BEGIN
                    ;WITH TargetRow AS (
                        SELECT TOP(1) * FROM NUMBERSEQUENCELIST WITH (ROWLOCK, READPAST) 
                        WHERE 
                        NUMBERSEQUENCEID = @numberid AND STATUS = 0 
                        and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition)
                        ORDER BY RecId
                    )
                    UPDATE TargetRow
                    SET 
                        STATUS = 4, TRANSID = @globalTransId,MODIFIEDTRANSACTIONID = @globalTransId, USERID = @UserId,MODIFIEDBY = @UserId,
                        SESSIONID = @sessionid,SESSIONLOGINDATETIME = @sessionLoginDateTime
                    OUTPUT 
                        CASE WHEN @extended != 0 THEN INSERTED.NEXTREC64 ELSE INSERTED.NEXTREC END
                    INTO @NextValueTable;
                    SELECT @nextValue = NextValue FROM @NextValueTable;
            END
            ELSE
            BEGIN           
                UPDATE top(1) [NUMBERSEQUENCELIST] with (rowlock, readpast)
                SET
                    STATUS=4, TRANSID=@globalTransId, MODIFIEDTRANSACTIONID=@globalTransId, USERID=@UserId,
                    MODIFIEDBY=@UserId, SESSIONID=@sessionid, SESSIONLOGINDATETIME=@sessionLoginDateTime,
                    @nextValue= CASE WHEN @extended != 0 THEN [NEXTREC64] ELSE [NEXTREC] END
                WHERE
                    NUMBERSEQUENCEID= @numberid and STATUS = 0 and (@PerformPartitionCheckFlag = 0 OR PARTITION = @Partition);
            END        
        END
        select @nextValue;
    END
    GO

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 247

#2
Siv Sagar Profile Picture

Siv Sagar 202 Super User 2025 Season 2

#3
Danny Bilodeau Profile Picture

Danny Bilodeau 193 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans