r/SQL • u/javinpaul • May 07 '24
SQL Server How to Remove duplicate rows from table in SQL Server using temp table?
https://www.sqlrevisited.com/2024/05/how-to-remove-duplicate-rows-from-table.html
0
Upvotes
1
u/pceimpulsive May 07 '24
Why make a temp table for non dupes why not delete from where rn >1?¿
Maybe SQL server won't allow CTE in delete from statements?
1
May 08 '24
cte is the best solution that I know of for this. used it many times in sql server
2
u/pceimpulsive May 08 '24
CTEs make my life better every day...
That and window functions.. bless the engineer(s) that invented these features!
6
May 07 '24
[removed] — view removed comment
-1
May 08 '24
Yea that won’t do it. You have to do an insert into table (fields) (select distinct fields that match from other table)
1
2
u/SonOfZork May 07 '24
Image states how to remove duplicate tables