我在我的 SQL Server 2005 上收到一个错误
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