Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how do you remove duplicate records? (mssql)

Posted on 2008-06-20
4
315 Views
Last Modified: 2008-06-20
i have a 70,000 record table but i think it should only have 35,000 because all of the records i looked at (when in id order) has a twin underneath it. is there an easy way of removing one of the records but keeping the other?
the only way i can think of doing it is to delete them both and then insert one again.
0
Comment
Question by:darkmooink
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21830268
is there any column that you can use to distinguish the 2 records?
if yes: it's easy
if not: it will not be straightforward...
0
 
LVL 3

Author Comment

by:darkmooink
ID: 21830445
no they are identical, there is no unique identifier
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 125 total points
ID: 21830523
SELECT DISTINCT col1, col2...
INTO #Temp
FROM urTable
TRUNCATE TABLE urTable
INSERT INTO urTable
SELECT * FROM #Temp
0
 
LVL 3

Author Comment

by:darkmooink
ID: 21831436
thankyou aneeshattingal that would have worked (i tryed it on test data) but i did something that deleted the whole table's data.  we should have the data somewhere else so it will hopefully only be missing for a week and a half till my manager gets back and finds the data again.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question