tsql - SQL query to find duplicate rows, in any table -



tsql - SQL query to find duplicate rows, in any table -

i'm looking schema-independent query. is, if have users table or purchases table, query should as capable of catching duplicate rows in either table without modification (other from clause, of course).

i'm using t-sql, i'm guessing there should general solution.

i believe should work you. maintain in mind checksum() isn't 100% perfect - it's theoretically possible false positive here (i think), otherwise can alter table name , should work:

;with cte ( select *, checksum(*) chksum, row_number() over(order getdate()) row_num my_table ) select * cte t1 inner bring together cte t2 on t2.chksum = t1.chksum , t2.row_num <> t1.row_num

the row_number() needed have way of distinguishing rows. requires order by , can't constant, getdate() workaround that.

simply alter table name in cte , should work without spelling out columns.

sql tsql

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -