#TempTable에서 준비 테이블에없는 모든 레코드를 찾으려고합니다. 비교가 16 개 필드 이상에서 이루어져야한다는 점에 유의해야합니다.여러 열을 사용하여 존재하지 않는다
여러 조합을 시도했지만 아무 것도 작동하지 않는 것 같습니다.
SELECT CustomerAccountNo FROM #TempTable
WHERE NOT EXISTS
(SELECT e.[CustomerAccountNo] ,
e.[MeterNo] ,
e.[CustomerName1] ,
e.[ServiceAddress1] ,
e.[ServiceAddress2] ,
e.[ServiceCity] ,
e.[ServiceState] ,
e.[ServiceZip] ,
e.[BillingAddress1] ,
e.[BillingAddress2] ,
e.[BillingAddress3] ,
e.[BillingCity] ,
e.[BillingState] ,
e.[BillingZip] ,
e.[BillingZip4] ,
e.[PrimaryPhoneNumber] FROM #TempTable e
JOIN dbo.Staging s
ON e.CustomerAccountNo = s.CustomerAccountNo AND
e.MeterNo = s.MeterNo AND
e.CustomerName1 = s.CustomerName1 AND
e.ServiceAddress1 = s.ServiceAddress1 AND
e.ServiceAddress2 = s.ServiceAddress2 AND
e.ServiceCity = s.ServiceCity AND
e.ServiceState = s.ServiceState AND
e.ServiceZip = s.ServiceZip AND
e.BillingAddress1 = s.BillingAddress1 AND
e.BillingAddress2 = s.BillingAddress2 AND
e.BillingAddress3 = s.BillingAddress3 AND
e.BillingCity = s.BillingCity AND
e.BillingState = s.BillingState AND
e.BillingZip = s.BillingZip AND
e.BillingZip4 = s.BillingZip4 AND
e.PrimaryPhoneNumber= s.PrimaryPhoneNumber
)
어떻게이 작동하지 않습니다
이 하나의 시도
? 너무 많은 기록을 남기고 있습니까? 부족한? 또는...? – Melanie이 코드 조합에서 모든 레코드가 다시 반환됩니다. 모든게 빠진 것처럼. 다른 사람들은 아무것도 얻지 못합니다 ... –
@HABO - 그들은 거기에서 왔습니다. #TempTable e JOIN dbo.Staging s – Hogan