Solved

how do you remove duplicate records? (mssql)

Posted on 2008-06-20
4
317 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
[X]
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
  • 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

751 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