TSQL: example how to find duplicate records

WITH R
AS
(SELECT ROW_NUMBER() OVER(PARTITION BY EANNummer ORDER BY V.Artikelnummer, AuspraegungID, ltrim(EANNummer)) as ‘rownumber’, V.Artikelnummer, AuspraegungID, EANNummer

FROM ArtikelVarianten V

INNER JOIN Artikel A on V.Mandant=A.Mandant AND V.Artikelnummer= A.Artikelnummer
where A.Aktiv = -1)

SELECT  * FROM R WHERE RowNumber >1 AND NOT EANNummer IS NULL

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s