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

  • Home
  • SEARCH
  • 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 9019801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:51:45+00:00 2026-06-16T04:51:45+00:00

ALTER PROCEDURE [dbo].[Update_MCR] @xmlString ntext ,@Message nvarchar(500) output AS BEGIN SET NOCOUNT ON; declare

  • 0
ALTER PROCEDURE [dbo].[Update_MCR]
     @xmlString  ntext
    ,@Message nvarchar(500) output
AS
BEGIN

    SET NOCOUNT ON;
    declare  @SL int,@Basic  float, @Grad_pay  float, @DA  float, @HRA  float, @MA  float, @Ptax  float, @Itax  float, @pf  float, @LIC  float, @Month_Of  datetime
    Declare @intDoc1 as int
    BEGIN TRANSACTION 
    print @xmlString
    exec sp_xml_preparedocument @intDoc1 OUTPUT, @xmlString
    declare Generate_Rq CURSOR FOR
    SELECT SL,Basic, Grad_pay, DA, HRA, MA, Ptax, Itax, pf, LIC,  Month_Of
    FROM OPENXML (@intDoc1,'/Salary/TransactionSalary',1)
    WITH ( SL int,Basic  float, Grad_pay  float, DA  float, HRA  float, MA  float, Ptax  float, Itax  float, pf  float, LIC  float, Month_Of  datetime)

    OPEN Generate_Rq

    FETCH next FROM Generate_Rq
    INTO @SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC,  @Month_Of

    WHILE @@Fetch_Status<>-1
        BEGIN
            Print 'Line  ' +@Basic+ '    '+ @Grad_pay+ '    '+ @DA+ '    '+ @HRA+ '    '+ @MA+ '    '+ @Ptax+ '    '+ @Itax+ '    '+ @pf+ '    '+ @Month_Of+ '    '+ @LIC+ '    '+ @SL

            UPDATE  [Monthly_Salary_Statement]  
            Set [Basic]=@Basic, [Grad_pay]=@Grad_pay, [DA]=@DA, [HRA]=@HRA, [MA]=@MA, [Ptax]=@Ptax, [Itax]=@Itax, [pf]=@pf,  [LIC]=@LIC
            Where  [SL]=@SL and month([Month_Of])=month(@Month_Of) and year([Month_Of])=year(@Month_Of)

            if(@@ERROR<>0)
                BEGIN
                    rollback transaction
                    Set @Message='sp_Update_Montly_Salary: ' + @@Error 
                    close Generate_Rq
                    deallocate Generate_Rq
                    Return
                END
            FETCH next FROM Generate_Rq
            INTO @SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC,  @Month_Of
        END
    CLOSE Generate_Rq
    DEALLOCATE Generate_Rq
    COMMIT TRANSACTION
    set  @Message='True'
END

Sample XML:

<Salary>
  <TransactionSalary SL="8" Basic="12560.00" Grad_pay="4800.00" DA="7812.00" HRA="2604.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="200.00" LIC="0.00" Month_Of="20-Dec-2012" /> 
  <TransactionSalary SL="7" Basic="9860.00" Grad_pay="4100.00" DA="6282.00" HRA="2094.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="0.00" LIC="0.00" Month_Of="20-Dec-2012" /> 
  <TransactionSalary SL="9" Basic="11850.00" Grad_pay="4800.00" DA="7493.00" HRA="2498.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="0.00" LIC="200.00" Month_Of="20-Dec-2012" /> 
  </Salary>'

Error:

Msg 8115, Level 16, State 8, Procedure Update_MCR, Line 42
Arithmetic overflow error converting decimal to data type numeric.

I am not able to find out the why this error occur and for which value. In case of insert I take another way as mention in this site. But again a face the same problem.

  • 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-06-16T04:51:46+00:00Added an answer on June 16, 2026 at 4:51 am

    I would:

    • change the datatype for @xmlString to XML – it’s XML, after all – right?
    • get rid of the cursor ! You don’t need it – it’s just a performance killer – drop it
    • get rid of the “old-style” OPENXML stuff – use the native XQuery support of SQL Server! Much easier to use

    So my procedure would be something like:

    ALTER PROCEDURE [dbo].[Update_MCR]
         @xmlString  XML,
         @Message nvarchar(500) output
    AS
    BEGIN
        SET NOCOUNT ON;
    
        BEGIN TRY
            BEGIN TRANSACTION 
    
            ;WITH trsal AS 
            (
                SELECT
                    SL = TrSal.value('@SL', 'int'),
                    [Basic] = TrSal.value('@Basic', 'decimal(16,2)'),
                    [Grad_Pay] = TrSal.value('@Grad_pay', 'decimal(16,2)'),
                    [DA] = TrSal.value('@DA', 'decimal(16,2)'),
                    [HRA] = TrSal.value('@HRA', 'decimal(16,2)'),
                    [MA] = TrSal.value('@MA', 'decimal(16,2)'),
                    [Ptax] = TrSal.value('@Ptax', 'decimal(16,2)'),
                    [Itax] = TrSal.value('@Itax', 'decimal(16,2)'),
                    [pf] = TrSal.value('@pf', 'decimal(16,2)'),
                    [LIC] = TrSal.value('@LIC', 'decimal(16,2)'),
                    [Month_Of] = TrSal.value('@Month_Of', 'datetime')
                 FROM 
                    @XmlString.nodes('/Salary/TransactionSalary') AS XTbl(TrSal)    
            )
            UPDATE [Monthly_Salary_Statement]  
            SET 
            [Basic] = trsal.Basic, 
            [Grad_pay] = trsal.Grad_pay, 
            [DA] = trsal.DA, 
            [HRA] = trsal.HRA, 
            [MA] = trsal.MA, 
            [Ptax] = trsal.Ptax, 
            [Itax] = trsal.Itax, 
            [pf] = trsal.pf, 
            [LIC] = trsal.LIC
            FROM
            trsal        
            WHERE
            [SL] = trsal.SL 
            AND MONTH([Month_Of]) = MONTH(trsal.Month_Of) 
            AND YEAR([Month_Of]) = YEAR(trsal.Month_Of)
    
          COMMIT TRANSACTION
    
          SET @Message = 'True'
    
        END TRY
        BEGIN CATCH
           ROLLBACK TRANSACTION
    
           SET @Message = 'sp_Update_Montly_Salary: ' + ERROR_MESSAGE()
        END
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ALTER PROCEDURE [dbo].[AmendInsertDuplicateFields] (@ReportID varchar(50)) AS BEGIN DECLARE @NewReportID VARCHAR(50) SET @NewReportID = NEWID()
I have the following procedure: ALTER PROCEDURE [dbo].[UpdateAllClients] @ClientIDs varchar(max) AS BEGIN SET NOCOUNT
I've created the following stored procedure: ALTER PROCEDURE [dbo].[ExampleSP] ( @SearchText NVARCHAR(4000), @ID INT
WhenI call this stored procedure: ALTER PROCEDURE [dbo].[GetSorted] ( @OrderByColumn nvarchar(256) ) AS SET
I Create this stored procedure ALTER PROCEDURE [dbo].[Stock_Master_Sp] @common nvarchar(1)='', @PK_ID int=0, @FK_StoneCategory_Master int=0,
I have sql server procedure, please see below. ALTER PROCEDURE [dbo].[uspInsertDelegate] ( @CourseID int,
I have a simple stored procedure like so: ALTER PROCEDURE [dbo].[spList_Report] @id INT AS
In SQL 2008 I've this easy-but-bad-write sp that works: ALTER PROCEDURE [dbo].[paActualizaCapacidadesDeZonas] AS BEGIN
ALTER PROCEDURE [dbo].[GetDocumentsAdvancedSearch] @SDI CHAR(10) = NULL ,@Client CHAR(4) = NULL ,@AccountNumber VARCHAR(20) =
ALTER PROCEDURE [dbo].[GetTimeSheetsAttendance] @WhereClause varchar AS EXEC ('Select vwEmployeeList.ID,vwEmployeeList.Code, tbGNClient.FName + '' '' +

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.