How to Delete Duplicate Records from a SQL Table

preview_player
Показать описание
Learn how to use a CTE to delete duplicate rows from a SQL Table. I'll be demonstrating this in SQL Server but the concepts are universal across most Relational Database Management Systems.

We will cover the CTE syntax, the ROW_NUMBER() Window Function and assigning flags within partitioned rows.

Enjoy!

🤝 Follow my Data content on Twitter:

🤝 I’m also sharing Data knowledge on Instagram:

🤝 Connect with me on LinkedIn:

🤝 View my Website:

Рекомендации по теме
Комментарии
Автор

That was super useful, thank you so much for your knowledge-sharing.

faresyounis
Автор

Hello man,
god bless your efforts.
A have a general enquiry as a new sql learner.
When i apply INSERT, UPDATE, or DELETE statement inside sql management studio, is the commit statement applied implicitly as part of the three former commands. The reason that i want to
make sure that when these three commands being applied would take effect on the database directly and at same time for all users.
Thanks for assisting me with my enquiry.

hasanmougharbel
Автор

Nice Video, helped me with my case.

Just some addition for everyone looking forward to use your method but they dont have only one primary key, like your EmployeeID.

just add those to your PARTITION BY function separated by comma. f.e.:

ROW_NUMBER() OVER (PARTITION BY FirstName, LastName, Deparment ORDER BY FirstName)

MaceGee
Автор

TIL DELETE FROM CTE. Thanks for sharing!

flexyourdata
Автор

Great video james.hope to learn more from you.came to ur channel after we connected on LinkedIn.hope to become as good as u In sql oneday.

surojeetghosh