July 5, 2005 at 11:39 am
Hi Friends,
My asp page is returning Divizion by zero error from the OLEDB Provider. I can open the recordset. But it occurs only while I loop through the records. The Query runs in SQL Query Analyzer very well, I can open the recordset through OLEDB Provider. But it prompts Division by zero error only after 3 records while issuing the Recordset.Movenext command.
I am using SQL Server 2000 in Win 2003 envirnment.
My Query:
--------------------------------------------------------------------------
SELECT DATEPART(mm, K.[Date]) AS [Month], K.[KPI_Code], K.[Field_Code], K.[Field_Desc], K.[KPI_Value], K.[SubValue_1], CASE WHEN M.[MasterValue] IS NULL THEN NULL ELSE CONVERT(DECIMAL(5,2), (K.[SubValue_1] * 100) /M.[MasterValue]) END AS [ReturnPercent]
FROM [OPS_KPI_Volume_Test] AS K
LEFT OUTER JOIN
(
SELECT [Field_Code], [SubValue_1] AS [MasterValue] FROM [OPS_KPI_Volume_Test]
WHERE [KPI_Code] = 7 and DATEPART(mm, [Date]) = 6
) AS M
ON K.[ReturnFieldCode] = M.[Field_Code]
WHERE K.[KPI_Code] = 7 and DATEPART(mm, K.[Date]) = 6
ORDER BY K.DisplayOrder
---------------------------------------------------------------------------
Is anyone there can help me? My email is cragesh@gmail.com
Regards,
Ragesh Chavarattil
July 5, 2005 at 11:47 am
Please do not cross-post, we monitor all boards.
Finish the thread here : http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=23&messageid=197077
July 6, 2005 at 12:43 am
you can use NULLIF function to avoid that error. It replaes the NULL value whenever the zero occurs in the denominator.
July 6, 2005 at 12:48 am
Thanks for your comments,
I can execute the statement in Query Analyzer and even open recordset. But I am getting the error only while looping through the records. And the error is raised from the OLEDB provider. Why it so? do you know?
Regards,
Ragesh
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply