[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Server DeDupe Table

Posted on 2016-08-22
3
Medium Priority
?
58 Views
Last Modified: 2016-08-22
The SQL Statement below returns data that for absolute sure...
Any row number > 1 is a dup record

What is the most efficient way to delet those records from the table?
There are no foreign keys etc...

SELECT      SalesSiteToChannelID,
            ChannelID ,
            SalesSiteID,
            ROW_NUMBER() OVER(PARTITION BY SalesSiteID ORDER BY ChannelID, SalesSiteID) AS RowNumber
FROM      ewSalesSitesToChannels
0
Comment
Question by:lrbrister
[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
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 41765806
;with cte as (
   --- Your table here
   SELECT SalesSiteToChannelID,
      ChannelID ,
      SalesSiteID,
      ROW_NUMBER() OVER(PARTITION BY SalesSiteID ORDER BY ChannelID, SalesSiteID) AS RowNumber
   FROM ewSalesSitesToChannels) 
DELETE from cte WHERE row_number > 1

Open in new window


Check out SQL Server Delete Duplicate Rows for a demo.
0
 

Author Closing Comment

by:lrbrister
ID: 41765807
Thanks
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41765966
Thanks for the accept, good luck with your project.  -JIm
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

649 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