I have a field called customer ID. I want to make it a primary key but it says there are duplicates. How do I find these so I can delete one of them? There's abuot 4,000 records so I can't really look through them.
Create a table with same structure,
I do this with
select top 1 into temptab from maintable
truncate temptab
insert into temptab
(Customerid)
(select distinct customerid from maintable)
Update temptab
set temptab.field1=maintable.field1,
temptab.field2=maintable.field2
from temptab, maintable
where temptab.customerid=maintable.customerid
You can then rename the table to maintable.
Then set primary key.
I would keep the main table to make sure you did not remove any data you wanted to keep.
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.