vinay.sindri Posted July 24, 2007 Share Posted July 24, 2007 Hi!How can we delete duplicated rows of a table in SQL Server. Link to comment Share on other sites More sharing options...
jhecht Posted July 25, 2007 Share Posted July 25, 2007 DELETE FROM table WHERE table_id_column NOT IN (select distinct table_id_column from table) Tried that? Link to comment Share on other sites More sharing options...
vinay.sindri Posted July 26, 2007 Author Share Posted July 26, 2007 DELETE FROM table WHERE table_id_column NOT IN (select distinct table_id_column from table) Tried that?What if no id column is there? Link to comment Share on other sites More sharing options...
Synook Posted July 26, 2007 Share Posted July 26, 2007 Good database design practice: always have index columns for tables (i.e. all of them except ones purely for relational purposes).But, if it is too late to insert an index then you will have to combine columns in an attempt to eliminate accidental deletions... umm... better to just define an index column lol Link to comment Share on other sites More sharing options...
jhecht Posted July 26, 2007 Share Posted July 26, 2007 Good database design practice: always have index columns for tables (i.e. all of them except ones purely for relational purposes).But, if it is too late to insert an index then you will have to combine columns in an attempt to eliminate accidental deletions... umm... better to just define an index column lol Yes, if it is a direct-access table, please, always use an ID. It makes it easier on you later.DELETE FROM table WHERE table_title_column NOT IN (select distinct table_title_column from table) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.