title: Why is this cursor giving an error?
body: <pre><code>ALTER PROCEDURE [dbo].[sp_Insert_Monthly_Salary_Req]
       @xmlString  ntext
      ,@Message nvarchar(500) output
  AS
  BEGIN
  
      SET NOCOUNT ON;
      declare  @Emp_SL int,@Basic  decimal(6,2), @Grad_pay  decimal(6,2), @DA  decimal(6,2), @HRA  decimal(6,2), @MA  decimal(6,2), @Ptax  decimal(6,2), @Itax  decimal(6,2), @pf  decimal(6,2), @LIC  decimal(6,2), @Month_Of  datetime
      Declare @intDoc1 as int
      BEGIN TRANSACTION 
      print @xmlString
      exec sp_xml_preparedocument @intDoc1 OUTPUT, @xmlString
      declare Generate_Rq CURSOR FOR
      SELECT Emp_SL,Basic, Grad_pay, DA, HRA, MA, Ptax, Itax, pf, LIC,  Month_Of
      FROM OPENXML (@intDoc1,'/Salaray/TransactionSalary',1)
      WITH ( Emp_SL int,Basic  decimal(6,2), Grad_pay  decimal(6,2), DA  decimal(6,2), HRA  decimal(6,2), MA  decimal(6,2), Ptax  decimal(6,2), Itax  decimal(6,2), pf  decimal(6,2), LIC  decimal(6,2), Month_Of  datetime)
  
      OPEN Generate_Rq
      FETCH next FROM Generate_Rq
      INTO @Emp_SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC,  @Month_Of
      print 'Line2'
      WHILE @@Fetch_Status&lt;&gt;-1
          BEGIN
              Print 'Line  ' +@Basic+ '    '+ @Grad_pay+ '    '+ @DA+ '    '+ @HRA+ '    '+ @MA+ '    '+ @Ptax+ '    '+ @Itax+ '    '+ @pf+ '    '+ @Month_Of+ '    '+ @LIC+ '    '+ @Emp_SL
  
              INSERT INTO [Monthly_Salary_Statement]([Basic], [Grad_pay], [DA], [HRA], [MA], [Ptax], [Itax], [pf], [Month_Of], [LIC], [Emp_SL])
              VALUES (@Emp_SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC,  @Month_Of)
              if(@@ERROR&lt;&gt;0)
                  BEGIN
                      rollback transaction
                      Set @Message='sp_Insert_PromtList: ' + @@Error 
                      close Generate_Rq
                      deallocate Generate_Rq
                      Return
                  END
              FETCH next FROM Generate_Rq
              INTO @Emp_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
  </code></pre>
  
  <hr>
  
  <p>The xml</p>
  
  <pre><code>&lt;Salaray&gt;
    &lt;TransactionSalary EmpSL="2" Basic="9860" Grad_pay="4100.00" DA="6282.00" HRA="2094" MA="300.00" Ptax="150.00" pf="2000" Itax="0.00" LIC="0.00" Month_Of="14/Dec/2012" /&gt; 
    &lt;TransactionSalary EmpSL="1" Basic="12560" Grad_pay="4800.00" DA="7812.00" HRA="2604.00" MA="300" Ptax="150.00" pf="2000" Itax="0.00" LIC="0.00" Month_Of="14/Dec/2012" /&gt; 
    &lt;TransactionSalary EmpSL="4" Basic="11850" Grad_pay="4800.00" DA="7493.00" HRA="2498.00" MA="300" Ptax="150.00" pf="2000" Itax="0.00" LIC="0.00" Month_Of="14/Dec/2012" /&gt; 
    &lt;/Salaray&gt;',
  </code></pre>
  
  <p>It shows ..</p>
  
  <blockquote>
    <p>Msg 8115, Level 16, State 8, Procedure sp_Insert_Monthly_Salary_Req,
    Line 26<br>
    Arithmetic overflow error converting nvarchar to data type numeric.<br>
    Msg 16917, Level 16, State 2, Procedure sp_Insert_Monthly_Salary_Req, Line 27<br>
    Cursor is not open.<br>
    Msg 16917, Level 16, State 1, Procedure sp_Insert_Monthly_Salary_Req, Line 47<br>
    Cursor is not open.</p>
  </blockquote>