我在尝试在临时表中插入记录时遇到问题
我有一张临时表#TmpCapacityTable
CapacityDate InstallerCode WorkAreadID FoxtelCodeID value
2/8/12 BAW 7 1510 3
2/8/12 BAW 7 1508 3
第二个临时表#TmpAdjustmentTable
CapacityDate InstallerCode WorkAreadID fFoxtelCodeID value
2/8/12 BAW 7 1510 1
2/8/12 BAW 7 1508 1
2/8/12 BAW 7 1509 1
我需要在#TmpCapacityTable
中插入那些不在#TmpAdjustmentTable
但在Insert into #TmpCapacityTable
select * from #TmpAdjustmentTable
where #TmpAdjustmentTable.CapacityDate not in (select #TmpCapacityTable.CapacityDate from #TmpCapacityTable)
and #TmpAdjustmentTable.WorkAreadID not in (select #TmpCapacityTable.WorkAreadID from #TmpCapacityTable)
and #TmpAdjustmentTable.InstallerCode not in (select #TmpCapacityTable.InstallerCode from #TmpCapacityTable)
and #TmpAdjustmentTable.FoxtelCodeID not in (select #TmpCapacityTable.FoxtelCodeID from #TmpCapacityTable)
中的行,仅在示例中代码1509
我正在使用
{{1}}
但它不起作用,我看不出是什么问题
有人能帮助我吗!!!
提前致谢
埃利安娜
答案 0 :(得分:0)
INSERT INTO TmpCapacityTable(CapacityDate, InstallerCode, WorkAreaID, FoxtelCodeID, value)
SELECT ta.CapacityDate, ta.InstallerCode, ta.WorkAreaID, ta.FoxtelCodeID, ta.value
FROM #TmpAdjustmentTable ta
LEFT OUTER JOIN #TmpCapacityTable tc
ON ta.CapacityDate = tc.CapacityDate
AND ta.InstallerCode = tc.InstallerCode
AND ta.FoxtelCodeID = tc.FoxtelCodeID
WHERE tc.value IS NULL