-1
我們有兩個銷售不同類型項目的系統。與Sandbox2中的客戶相比,我們希望在Sandbox1中顯示只有客戶的客戶。我使用了WHERE NOT EXISTS,但我不確定它是否正常工作。當我嘗試運行它時出現錯誤:將nvarchar值「MSTO15」轉換爲數據類型int時轉換失敗。所以我不確定是什麼原因造成的,或者我是否在正確的軌道上查詢。SQL查詢不存在
任何幫助,將不勝感激。
SELECT [Account #], Accounts, [Prior Annual], [Prior Annual1], [Prior Annual2]
FROM Sandbox1.dbo.SalesHistory as s
WHERE NOT EXISTS
(SELECT *
FROM Sandbox2.dbo.customer_master as m
WHERE s.[Account #] =
m.customer_number)
你能分享一些示例數據和要達到的效果嗎? – Mureinik
s。[Account#]和m.customer_number的數據類型是什麼?根據錯誤消息,一個似乎是INTEGER,另一個是CHAR ...... – dnoeth
一個是int,另一個是varchar –