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
?