I have an SQL tables [Keys] that has various rows such as:
[ID] [Name] [Path] [Customer]
1 Key1 Key1 InHouse
2 Key2 Key2 External
3 Key1 Key1 InHouse
4 Key1 Key1 InHouse
5 Key1 Key1 InHouse
Obviously IDs 1,3,4,5 are all exactly the same and I would like to be left with only:
[ID] [Name] [Path] [Customer]
1 Key1 Key1 InHouse
2 Key2 Key2 External
I cannot create a new table/database or change the unique identifier (which is currently ID) either. I simply need an SQL script I can run to clean out the duplicates (I know how they got there and the issue has been fixed but the Database is still currently invalid due to all these duplicate entires).
Any help would be greatly appreciated.
Thanks,Since you want nothing left in your table (see your example above), a simple TRUNCATE TABLE should do nicely!
-PatP|||Pat: Funny :) Sorry I posted that too quick, updated it now.
Thanks,|||Oh, so now you get picky about things! ;)
Try this:DELETE FROM myTable
WHERE EXISTS (SELECT *
FROM myTable AS foo
WHERE foo.[name] = myTable.[name]
AND foo.[path]= myTable.[path]
AND myTable.[id] < foo.[id]-PatP
Showing posts with label various. Show all posts
Showing posts with label various. Show all posts
Thursday, March 22, 2012
Deleting duplicate rows from a table, having no primary key
I am looking at various methods to delete records from a table which has duplicate records and does not have a foriegn key, in a single query.
One of the methods is using the rowid.
Looking for more.
VisheetalThat would be the easiest.sql
One of the methods is using the rowid.
Looking for more.
VisheetalThat would be the easiest.sql
Wednesday, March 21, 2012
Deleting Conflict tables
Hi,
While trying Merge replication for various publications, many conflict
tables were created in the publisher database. Even after deleting the
publications, they haven't gone off and neither can I delete them.
Could someone suggest, how to delete the conflict tables?
Thanks!
PS.
Sometimes the sp_removedbreplication will not remove them. If you ALTER the
tables, then you should be able to just drop them.
Rand
This posting is provided "as is" with no warranties and confers no rights.
|||Hi,
Thanks for the response. I tried deleting them through Enterprise
Manager and I got errors, but for some reason, I am able to drop the
conflict tables by dropping them from query analyzer.
PS.
rboyd@.onlinemicrosoft.com (Rand Boyd [MSFT]) wrote in message news:<g3Y0gn6UEHA.1996@.cpmsftngxa10.phx.gbl>...
> Sometimes the sp_removedbreplication will not remove them. If you ALTER the
> tables, then you should be able to just drop them.
> Rand
> This posting is provided "as is" with no warranties and confers no rights.
sql
While trying Merge replication for various publications, many conflict
tables were created in the publisher database. Even after deleting the
publications, they haven't gone off and neither can I delete them.
Could someone suggest, how to delete the conflict tables?
Thanks!
PS.
Sometimes the sp_removedbreplication will not remove them. If you ALTER the
tables, then you should be able to just drop them.
Rand
This posting is provided "as is" with no warranties and confers no rights.
|||Hi,
Thanks for the response. I tried deleting them through Enterprise
Manager and I got errors, but for some reason, I am able to drop the
conflict tables by dropping them from query analyzer.
PS.
rboyd@.onlinemicrosoft.com (Rand Boyd [MSFT]) wrote in message news:<g3Y0gn6UEHA.1996@.cpmsftngxa10.phx.gbl>...
> Sometimes the sp_removedbreplication will not remove them. If you ALTER the
> tables, then you should be able to just drop them.
> Rand
> This posting is provided "as is" with no warranties and confers no rights.
sql
Subscribe to:
Posts (Atom)