Here is what I am trying to accomplish...
But I get an error
SELECT * FROM
dbo.AP1_001VendorMaster
WHERE EXISTS
(SELECT NULL FROM
B.[VendorNumber] = dbo.AP1_001VendorMaster.VendorNumber
AND B.[VendorName] = dbo.AP1_001VendorMaster.VendorName
GROUP BY
B.VendorNumber, B.VendorName
HAVING
dbo.AP1_001VendorMaster.VendorNumber < Max(B.VendorNumber)
)
**************************
Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '='.
sELECT * FROM
dbo.AP1_001VendorMaster
WHERE EXISTS
(SELECT NULL FROM
B.VendorNumber = dbo.AP1_001VendorMaster.VendorNumber
GROUP BY
B.VendorNumber
HAVING
dbo.AP1_001VendorMaster.VendorNumber < Max(B.VendorNumber)
)
Ran that script, the problem with that is it returns all Rows in the Table, the table has duplicated itself once, so before I had 273 rows and now I have 546 rows, and every vendor is listed twice.
So, I have to find all the Duplicates and delete them. I ran your script and it returns 546 rows whcih means it sees all of them as Duplicates.
Try SELECT DISTINCT * FROM dbo.AP1_001VendorMaster
If that returns every row, then they aren't duplicates. SOMETHING is different in each row. Do you have a column that is an IDENTITY column? (IDENTITY autonumbers each entry). If so, then name each column in your SELECT and leave out that column.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.