freshers/Experienced Dotnet jobs

21/07/2011

How to delete duplicate rows from tables with no primary key!

Ans) Use SET ROWCOUNT value

Ex:-     SET ROWCOUNT 2
           DELETE FROM table_name WHERE somecolumn1=somecolumnvalue
           SET ROWCOUNT 0

         Imagine a table having 3 similar rows.The above delete statement executes 2 times deleting the extra 2 rows.Dont forget to set ROWCOUNT to 0 after succesfull query execution.



No comments:

Post a Comment