CREATE TABLE dbo.authors
(
PK_Column INT IDENTITY,
Authorname VARCHAR(50)
)
GO
INSERT dbo.authors(Authorname)
SELECT 'Author1'
UNION ALL SELECT 'Author1'
UNION ALL SELECT 'Author1'
UNION ALL SELECT 'Author2'
UNION ALL SELECT 'Author2'
UNION ALL SELECT 'Author3'
UNION ALL SELECT 'Author3'
UNION ALL SELECT 'Author4'
GO
SELECT * FROM dbo.authors
Go
DELETE authors
FROM authors a
LEFT OUTER JOIN
(
SELECT Authorname, pk_column = MIN(PK_Column)
FROM dbo.authors
GROUP BY Authorname
) x
ON a.pk_column = x.pk_column
WHERE x.pk_column IS NULL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment