我我的SQL Server 2005中的錯誤SQL 8115算術溢出錯誤轉換數字數據類型數字
Server: Msg 8115,
Arithmetic overflow error converting numeric to data type numeric.
當我嘗試插入一個值上獲得= X
(十進制(3,2))* Y
(INT)
在一列MYCOLUMN
類型DECIMAL (10,3)
如何解決這個問題呢?
UPDATE
一些代碼波紋管,以瞭解情況
-- ============================================================
-- 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
使用正確的數據類型的SQL Fiddle with demo?看起來像「DECIMAL(10,3)」不夠大。我們不能告訴你什麼是正確的,除非你告訴我們X和Y的最大值。 –
@Aaron Bertrand:你是什麼意思「X和Y的最大值」? – serhio
@serhio我認爲他的意思正是他所說的。什麼是您期望傳遞給X和Y的最小和最大值? – Mansfield