
November 7th, 2003, 11:46 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Location: Salt Lake City, UT
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
SQL Query for moving duplicate records
Please help me out... I am using the following SQL Query in MS SQL Server 2000.
' COPY DUPS WITHIN THE STAGINGLIST TABLE TO THE DUPLICATES TABLE, THESE ARE FROM HITTING THE SUBMIT BUTTON MORE THAN ONCE
strSQL = "INSERT INTO Duplicates (SourceID, LeadDate, Source, FirstName, LastName, Email, Address1, Address2, City, State, Zip, Phone, AltPhone, Fax, BestTime, ProcessDate) " &_
"SELECT SourceID, LeadDate, Source, FirstName, LastName, Email, Address1, Address2, City, State, Zip, Phone, AltPhone, Fax, BestTime, ProcessDate " &_
"FROM StagingList (nolock) " &_
"WHERE LeadID IN (SELECT LeadID FROM StagingList A INNER JOIN StagingList B ON A.Phone = B.Phone " &_
"WHERE A.LeadID > B.LeadID )"
cn.Execute strSQL
I am getting this error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Ambiguous column name 'LeadID'.
/wheelchair/index.asp, line 338
I know that error means that I have not qualified what table the field is coming from, but as far as I can tell I have. Could somebody please help me with this code, or suggest a better way to check for duplicate records.
Travis Cable
|