Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete duplicate fields in a table

Status
Not open for further replies.

Cloonalt

Programmer
Jan 4, 2003
354
US
I have a table with a field that has duplicate values. The rest of the record may not be unique.

So, for instance, if my table has two (or more) values of Mary in a field called FirstName, I want to leave only one of them, even if the address is not the same. (This is just an example)
It doesn't matter which ones get deleted. Can I do that in a SQL statement?

Thanks.
 
PHV, that looks like it will work. However, I execute

DELETE DCN
FROM Daily_Dat
WHERE ID Not In (SELECT Max(ID) FROM Daily_Dat GROUP BY DCN)

and get a message "Server: Msg 208, Level 16, State 1, Line 1 Invalid object name 'DCN'."

Thanks for your help!
 
How are ya Cloonalt . . .

. . . and if you include the square brackets [blue][][/blue] ?

Calvin.gif
See Ya! . . . . . .
 
And this ?
DELETE FROM Daily_Dat
WHERE ID Not In (SELECT Max(ID) FROM Daily_Dat GROUP BY DCN)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top