DEV Community

Saravanan Muniraj
Saravanan Muniraj

Posted on

1

Eliminate duplicate values in a table

In SQL server, the "PARTITION BY" clause is utilized to divide a result set into partitions depending on the values of one or more columns. This feature can be employed to eliminate duplicate values in a table.

WITH CTE AS
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY Column_Name ORDER BY Column_Name ) AS RN
FROM Table_Name
)

DELETE FROM CTE WHERE RN<>1

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay