title: SQL 8115 Arithmetic overflow error converting numeric to data type numeric
body: <p>I obtain on my SQL Server 2005 an error</p>
  
  <pre><code>Server: Msg 8115, 
  Arithmetic overflow error converting numeric to data type numeric.
  </code></pre>
  
  <p>When I try to insert a value = <strong><code>X</code></strong>(DECIMAL(3,2)) * <strong><code>Y</code></strong>(INT)<br>
  in a column <code>MYCOLUMN</code> typed <code>DECIMAL (10,3)</code></p>
  
  <p>How to workaround this problem?</p>
  
  <p>UPDATE</p>
  
  <p>some code bellow to understand the situation</p>
  
  <pre><code>-- ============================================================
  --   Table : GP_WGENTH
  -- ============================================================
  CREATE TABLE #GP_WGENTH
  (
       KEYINTERNAL                     CHAR(32)              NOT NULL,
       KEYHOUR                         INT                   NOT NULL,
       FIRM                            CHAR(5)               NOT NULL,
       CENTRE                          CHAR(2)               NOT NULL,
       SERVICE                         CHAR(6)               NOT NULL,
       AGENT                           CHAR(5)               NOT NULL,
       VERSION                         VARCHAR(3)            NOT NULL,
       DATE_ROULEMENT                  DATETIME              NOT NULL,
       SERVICEINSTANCE                 SMALLINT              NOT NULL,
       TYPEHOUR                        CHAR(9)               NOT NULL,
       QUANTITEFIXE                    DECIMAL(12,2)         NULL    ,
       TYPECMP                         INT                   NULL    ,
       PERCENTCALC                     DECIMAL(3,2)          NULL    
  )
  -- ============================================================
  --   Table : GP_WGENSVCTH
  -- ============================================================
  CREATE TABLE #GP_WGENSVCTH
  (
      KEYINTERNAL                     CHAR(32)              NOT NULL,
      KEYHOUR                         INT                   NOT NULL,
      FIRM                            CHAR(5)               NOT NULL,
      CENTRE                          CHAR(2)               NOT NULL,
      SERVICE                         CHAR(6)               NOT NULL,
      AGENT                           CHAR(5)               NOT NULL,
      VERSION                         VARCHAR(3)            NOT NULL,
      DATE_ROULEMENT                  DATETIME              NOT NULL,
      SERVICEINSTANCE                 SMALLINT              NOT NULL,
      TYPEHOUR                        CHAR(9)               NOT NULL,
      VALUE                           DECIMAL(10,3)         NOT NULL
  )
  GO
  
  INSERT INTO #GP_WGENSVCTH 
              (KEYINTERNAL, 
               KEYHOUR, 
               FIRM, 
               CENTRE, 
               SERVICE, 
               AGENT, 
               VERSION, 
               DATE_ROULEMENT, 
               SERVICEINSTANCE, 
               TYPEHOUR, 
               VALUE) 
  SELECT WTH.KEYINTERNAL, 
         WTH.KEYHOUR, 
         WTH.FIRM, 
         WTH.CENTRE, 
         WTH.SERVICE, 
         WTH.AGENT, 
         WTH.VERSION, 
         WTH.DATE_ROULEMENT, 
         WTH.SERVICEINSTANCE, 
         WTH.TYPEHOUR, 
         WTH.PERCENTCALC * SUM(SC.LENGTH) -- !!! BOOOM !!!!!!!!! HERE
  FROM   #GP_WGENTH WTH 
         INNER JOIN GP_SERVICE_HABILLAGE_COMPONENT SC 
                 ON WTH.FIRM = SC.FIRM 
                    AND WTH.CENTRE = SC.CENTRE 
                    AND WTH.SERVICE = SC.SERVICE 
                    AND WTH.VERSION = SC.VERSION 
                    AND WTH.TYPECMP = SC.TYPECMP 
  WHERE  WTH.KEYINTERNAL = 'august 23 2012  10:45:21:027PM     ' 
         AND SC.LENGTH IS NOT NULL 
  GROUP  BY WTH.KEYINTERNAL, 
            WTH.KEYHOUR, 
            WTH.FIRM, 
            WTH.CENTRE, 
            WTH.SERVICE, 
            WTH.AGENT, 
            WTH.VERSION, 
            WTH.DATE_ROULEMENT, 
            WTH.SERVICEINSTANCE, 
            WTH.TYPEHOUR, 
            WTH.PERCENTCALC 
  </code></pre>