SQLServer2005でエラーが発生します
Server: Msg 8115,
Arithmetic overflow error converting numeric to data type numeric.
入力
した列に値= X
(DECIMAL(3,2))* Y
(INT)を挿入しようとするとMYCOLUMN
DECIMAL (10,3)
この問題を回避するにはどうすればよいですか?
アップデート
状況を理解するための以下のコード
-- ============================================================
-- 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