tag:blogger.com,1999:blog-2328222207349876984.post5307852076919381740..comments2024-03-02T15:36:45.785-08:00Comments on SQL Tact: Removing Identical Duplicate RowsUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2328222207349876984.post-16603579753683976452012-02-28T07:12:28.555-08:002012-02-28T07:12:28.555-08:00This is ann excelent article. I was looking for th...This is ann excelent article. I was looking for that code for a long time.<br />Thanks a lot.<br /><br />AlexAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2328222207349876984.post-50244274394293029972012-02-28T06:52:39.928-08:002012-02-28T06:52:39.928-08:00Anonymous- thanks for replying. The delete in my...Anonymous- thanks for replying. The delete in my second example and the CTE delete in your example return the same exact execution plan. Six of one, half a dozen of the other...whttps://www.blogger.com/profile/04313158818403554742noreply@blogger.comtag:blogger.com,1999:blog-2328222207349876984.post-19266633646185015072012-02-28T06:33:49.503-08:002012-02-28T06:33:49.503-08:00--This can be done in one step with a CTE
create t...--This can be done in one step with a CTE<br />create table MyTable(<br />a int null,<br />b int null,<br />c int null,<br />d int null)<br /><br />insert MyTable<br />select 1,2,3,4<br />insert MyTable<br />select 1,2,3,5<br /><br />select * from MyTable<br /><br />--Ed's magical dedupeme code<br />;With DeDupeMe As ( <br /> Select<br /> a,b,c,<br /> Row_Number() OVER( Partition By a,b,c<br /> Order By d) as RowNumber <br /> From MyTable ) <br /> Delete From DeDupeMe <br /> Where RowNumber > 1Anonymousnoreply@blogger.com