SMS SQL for Duplicate Collection Names
Recently, I've found many collections with duplicate names. The dupes can cause problems when managing those collections. I quickly created the following SQL to find the offending collections.
-- This SQL query will show collections with duplicate names.
Select parentCollectionID, ParentCollection.Name, v_Collection.CollectionID, v_Collection.Name from v_Collection
left outer join
v_CollectToSubCollect
on v_Collection.collectionid=v_CollectToSubCollect.subcollectionid
left outer join
v_Collection ParentCollection
on v_CollectToSubCollect.parentCollectionID = ParentCollection.collectionid
where v_Collection.Name in (Select Name from v_Collection Group By Name Having Count(*)>1)
-- This SQL query will show collections with duplicate names.
Select parentCollectionID, ParentCollection.Name, v_Collection.CollectionID, v_Collection.Name from v_Collection
left outer join
v_CollectToSubCollect
on v_Collection.collectionid=v_CollectToSubCollect.subcollectionid
left outer join
v_Collection ParentCollection
on v_CollectToSubCollect.parentCollectionID = ParentCollection.collectionid
where v_Collection.Name in (Select Name from v_Collection Group By Name Having Count(*)>1)
Comments