How to delete duplicate record where PK is uniqueidentifier field

I want to know the way we can remove duplicate records where PK is uniqueidentifier. I have to delete records on the basis of duplicate values in a set of fields.we can use option to get temptable using Row_Number() and except row number one we can delete rest or the records. But I wanted to build one liner query. Any suggestion?

Answers


You can use CTE to do this, without seeing your table structure here is the basic SQL

;with cte as
(
    select *, row_number() over(partition by yourfields order by yourfields) rn
    from yourTable
)
delete
from cte
where rn > 1

Need Your Help

Plotting the spectrogram

c++ fftw spectrogram

Using the answer to this link:Spectrogram C++ library I have written a code to calculate the spectrogram of a sinusoidal signal:

how to detect tcp client connect to server in c++

c++ linux networking tcp tcpclient

I have a tcp client/server, and I want to detect connection loss in client side; because my client have multiple interfaces and at a time I connected to server with one of them, I want to know how to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.