Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Arithmetic overflow error converting numeric to data type numeric Expand / Collapse
Author
Message
Posted Monday, October 8, 2012 1:53 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, July 28, 2014 7:39 AM
Points: 170, Visits: 269
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.
Post #1369656
Posted Monday, October 8, 2012 2:58 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:40 AM
Points: 7,134, Visits: 13,521
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
Post #1369676
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse