deleting duplicate rows
-
how can we delete duplicate rows when we are not using constraints usings query only kishore kumar.B
-
Select all the field you are concerned about and do a group by with a having Something like this: Select col1, col2, col3, col4, col5 from yourTable group by col1, col2, col3, col4, col5 having count(*) > 1 Hope that helps. Ben
-
it can't deleting it only selecting. for select we are also select select DISTINCT * from tablename i need for deleting not for selecting kishore
The query I gave you is to identify the duplicates. Once you have the duplicates there are several things you can do to delete them. If you already know how to identify the duplicates then you should be able to delete them. You can not use a distinct since that removes the duplicates. Do you have any id column or key column to uniquely identify each column? Ben
-
The query I gave you is to identify the duplicates. Once you have the duplicates there are several things you can do to delete them. If you already know how to identify the duplicates then you should be able to delete them. You can not use a distinct since that removes the duplicates. Do you have any id column or key column to uniquely identify each column? Ben
-
any one i what that means the table that can have duplicate rows or particular rows.i already mension i can't give any constraints .
Ok well, if you don't have any unique key you should create one. Add a new column that is an identity. Then if you really don't which record you keep you can do a delete statement like this: delete from yourTable yt join (Select max(id),col1, col2, col3, col4, col5 from yourTable group by col1, col2, col3, col4, col5 having count(*) > 1) temp on yt.id = temp.id Ben