为什么得到错误:算术溢出错误将数字转换为数据类型数字

时间:2012-05-09 14:43:13

标签: sql sql-server sql-server-2008 sql-server-2005

SELECT 
    TradeId,
    Trade_SecurityId,
    SecurityType.*, 
    Trade_ParAmount Quantity 
INTO 
    #Securities 
FROM 
    Fireball.dbo.PreAssignSecurityType SecurityType
INNER JOIN 
    Fireball_RawImportData.dbo.Import_WSO_TradeReport TradeReport ON 
        SecurityType.NativeTradeId = TradeReport.Trade_ID AND
        TradeReport.Trade_TradeDate = SecurityType.TradeDate
INNER JOIN
    Fireball..Trade ON
        Trade.NativeTradeId = SecurityType.NativeTradeID
WHERE 
    SecurityType.TradeDate = '2012-02-02'

之后

INSERT INTO 
    Fireball..IRPTrade 
    (TradeId, Par, TradeFee, AccruedInterest, AccruedPIK, AccruedFees)
SELECT 
    TradeId, 
    Par, 
    TradeFee, 
    AccruedInterest, 
    AccruedPIK, 
    AccruedFees 
FROM 
    Fireball..bondTrade 
WHERE 
    TradeId IN 
    (
    SELECT 
        TradeId 
    FROM 
        #Securities 
    WHERE 
        SecurityType = 'IRP' OR 
        SecurityType = 'IRS'
    ) AND
    NOT EXISTS(
        SELECT  *
        FROM -- GETTING ERROR AT THIS LINE WHY :(
        Fireball..IRPTrade
    WHERE
        TradeId = bondTrade.TradeId)

表定义:

BondTradeId int Unchecked
TradeId int Unchecked
Par decimal(32, 4)  Checked
TradeFee    decimal(32, 4)  Checked
AccruedInterest decimal(32, 4)  Checked
AccruedPIK  decimal(32, 4)  Checked
AccruedFees decimal(32, 4)  Checked
        Unchecked

IRPTradeId  int Unchecked
TradeId int Unchecked
Par decimal(32, 4)  Checked
TradeFee    decimal(32, 4)  Checked
AccruedInterest decimal(32, 4)  Checked
AccruedPIK  decimal(32, 4)  Checked
AccruedFees decimal(32, 4)  Checked
        Unchecked

可能是表格decimal(32,4)Fireball..IRPTrade中的列值超过Fireball..bondTrade之一?

2 个答案:

答案 0 :(得分:1)

没有表的定义,很难回答:) 基于错误消息,它很可能是在INSERT期间引发的错误,因为来自VARCHAR列的数据无法正确转换为INT列。

答案 1 :(得分:1)

上次我收到类似的错误是因为数字字段中的某个值设置为NaN,而不是数字,更正了值或删除了行,之后很好。