SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Arithmetic overflow error converting numeric to data type numeric


Arithmetic overflow error converting numeric to data type numeric

Author
Message
hoseam
hoseam
SSC-Addicted
SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)SSC-Addicted (472 reputation)

Group: General Forum Members
Points: 472 Visits: 430
Hi

I have this code:

SELECT
[Policy_Id] = SNAP.POLICY_ID
,[Mex_Id] = FR.INV_PTF_NAME
,[Rebate_Amount_Gross] = ISNULL(CONVERT(DECIMAL(6,2),((FR.REBATE_RATE * SNAP.TOTAL_UNITS)/100)), 0.00)

and I get this error:
Arithmetic overflow error converting numeric to data type numeric.

please help.
ChrisM@Work
ChrisM@Work
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16494 Visits: 19557
hoseam (10/8/2012)
Hi

I have this code:

SELECT
[Policy_Id] = SNAP.POLICY_ID
,[Mex_Id] = FR.INV_PTF_NAME
,[Rebate_Amount_Gross] = ISNULL(CONVERT(DECIMAL(6,2),((FR.REBATE_RATE * SNAP.TOTAL_UNITS)/100)), 0.00)

and I get this error:
Arithmetic overflow error converting numeric to data type numeric.

please help.



Examine the Rebate_Amount_Gross values and check for yourself if they will fit into a decimal (6,2);
SELECT 
[Policy_Id] = SNAP.POLICY_ID
,[Mex_Id] = FR.INV_PTF_NAME
,x.[Rebate_Amount_Gross]
FROM ...
CROSS APPLY (SELECT [Rebate_Amount_Gross] = (FR.REBATE_RATE * SNAP.TOTAL_UNITS)/100) x
ORDER BY x.[Rebate_Amount_Gross] DESC



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search