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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting duplicate records 2

Status
Not open for further replies.

obuspider

Programmer
Oct 31, 2002
78
0
0
US
I just discovered to records in my sql db that are duplicates. I need to delete them, but apparently have the wrong syntax. Can someone help? The records look like the following

site overp
003 1
 
Unless there is something unique in at least one column to differentiate between the two records, you will have to delete them both and then re-insert one.
 
In a normalised database there should always be something that uniquely identifies a row in a table - the Primary Key. Maybe you should consider implementing this on your table(s) to avoid this situation in the future? --James
 
You could do this:

select distinct site,overp into #mytable from Table
go
truncate Table
go
Insert Table
Select * from #mytable
go

Hope this helps
 
JamesLean,

You are right. Unfortunately, I'm working off a db that was created and is maintained by someone else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top