Hi guys needs your support and expert openion, i have make a cursor which itrates and store values in variable, further I have insert that variable value into table which is perfectly working.. now the issue is i have 6000 rows curor start fetching rows and insert them into table one by one but after inserting some rows its get out form while loop and execute those statements which are written out side cursor and then after that gets back to Cursors while loop and insert rest of the lines, i dont know why it happes and also dont know how to fix it..

SET @XMLDistProdAttrib = '<DistributorProductAttributeID><![CDATA['+ CASE WHEN @DPADistributorProductAttributeID IS NULL THEN '' ELSE @DPADistributorProductAttributeID END +']]></DistributorProductAttributeID> <ProductID><![CDATA['+ CASE WHEN @DPAProductID IS NULL THEN '' ELSE @DPAProductID END +']]></ProductID> <DistributorID><![CDATA['+ CASE WHEN @DPADistributorID IS NULL THEN '' ELSE @DPADistributorID END +']]></DistributorID> <LocationID><![CDATA['+ CASE WHEN @DPALocationID IS NULL THEN '' ELSE @DPALocationID END +']]></LocationID> <ProductNumber><![CDATA['+ CASE WHEN @DPAProductNumber IS NULL THEN '' ELSE @DPAProductNumber END +']]></ProductNumber> <ProductCode><![CDATA['+ CASE WHEN @DPAProductCode IS NULL THEN '' ELSE @DPAProductCode END +']]></ProductCode> <ProductAlias><![CDATA['+ CASE WHEN @DPAProductAlias IS NULL THEN '' ELSE @DPAProductAlias END +']]></ProductAlias> <DistributorAllowance><![CDATA['+ CASE WHEN @DPADistributorAllowance IS NULL THEN '' ELSE @DPADistributorAllowance END +']]></DistributorAllowance> <DistributorAllowancePercentage><![CDATA['+ CASE WHEN @DPADistributorAllowancePercentage IS NULL THEN '' ELSE @DPADistributorAllowancePercentage END +']]></DistributorAllowancePercentage> <SellingAllowance><![CDATA['+ CASE WHEN @DPASellingAllowance IS NULL THEN '' ELSE @DPASellingAllowance END +']]></SellingAllowance> <FMR><![CDATA['+ CASE WHEN @DPAFMR IS NULL THEN '' ELSE @DPAFMR END +']]></FMR> <ValidFrom><![CDATA['+ CASE WHEN @DPAValidFrom IS NULL THEN '' ELSE @DPAValidFrom END +']]></ValidFrom> <ValidTo><![CDATA['+ CASE WHEN @DPAValidTo IS NULL THEN '' ELSE @DPAValidTo END +']]></ValidTo> <PassOnFMR><![CDATA['+ CASE WHEN @DPAPassOnFMR IS NULL THEN '' ELSE @DPAPassOnFMR END +']]></PassOnFMR> <ProductSegment><![CDATA['+ CASE WHEN @DPAProductSegment IS NULL THEN '' ELSE @DPAProductSegment END +']]></ProductSegment>'