Hi,
See example SQL Server script below. Run at your own risk. But might be helpful as a starting point for your solution...
SQL Server Script
_______________
declare @f_name varchar(2048)
declare @f_id int
declare @f_guid varchar (2048)
declare @l_name varchar (2048)
declare @l_id int
declare @l_guid varchar (2048)
declare @root_guid varchar (2048)
declare @stereotype varchar (2048)
-- set the root guid and stereotype of the objects to be merged
SET @root_guid = '{12D2B424-9C14-4f64-AA68-3DF1ABCD9858}';
SET @stereotype = 'Application';
declare c1 scroll cursor for
select distinct o2.alias, o2.object_id, o2.ea_guid from (
select distinct t.alias, t.stereotype from t_object t
where t.Package_ID IN (select distinct Package_ID from branch where
root_guid = @root_guid)
and t.alias is not null
and t.stereotype = @stereotype
group by t.alias, t.stereotype having count (*) > 1)
o1 join t_object o2 on o1.alias = o2.alias and o1.stereotype = o2.stereotype and o2.Package_ID IN (
select distinct Package_ID from branch where root_guid = @root_guid)
order by o2.alias, o2.object_id
open c1
while (1=1)
begin
fetch next from c1 into @f_name, @f_id, @f_guid
print 'first = ' + @f_name + '(' + cast (@f_id as varchar (

) + ')'
while (1=1)
begin
fetch next from c1 into @l_name, @l_id, @l_guid
if @f_name = @l_name
begin
print 'last = ' + @l_name + '(' + cast (@l_id as varchar (

) + ')'
delete from t_object where object_id = @l_id;
delete from t_xref where Client = @l_guid;
update t_diagramobjects set object_id = @f_id where object_id = @l_id;
update t_attribute set object_id = @f_id where object_id = @l_id;
update t_attributeconstraints set object_id = @f_id where object_id = @l_id;
update t_method set object_id = @f_id where object_id = @l_id;
update t_objectconstraint set object_id = @f_id where object_id = @l_id;
update t_objecteffort set object_id = @f_id where object_id = @l_id;
update t_objectfiles set object_id = @f_id where object_id = @l_id;
update t_objectmetrics set object_id = @f_id where object_id = @l_id;
update t_objectproblems set object_id = @f_id where object_id = @l_id;
update t_objectproperties set object_id = @f_id where object_id = @l_id;
update t_objectrequires set object_id = @f_id where object_id = @l_id;
update t_objectresource set object_id = @f_id where object_id = @l_id;
update t_objectrisks set object_id = @f_id where object_id = @l_id;
update t_objectscenarios set object_id = @f_id where object_id = @l_id;
update t_objecttests set object_id = @f_id where object_id = @l_id;
update t_objecttrx set object_id = @f_id where object_id = @l_id;
update t_operation set object_id = @f_id where object_id = @l_id;
update t_object set ParentID = @f_id where ParentID = @l_id
update t_connector set start_object_id = @f_id where start_object_id = @l_id;
update t_connector set end_object_id = @f_id where end_object_id = @l_id;
delete from t_objectproperties where Object_ID = @f_id and propertyId IN (
select o2.PropertyID from t_objectproperties o2 where o2.Object_ID = @f_id AND EXISTS
(select o3.Object_ID, o3.Property from t_objectproperties o3 where o2.Object_ID = o3.Object_ID and o2.Property = o3.Property
group by o3.Object_ID, o3.Property, o3.Value
having COUNT (*) > 1))
and PropertyID not in (
select MIN (o2.propertyID) from t_objectproperties o2 where o2.Object_ID = @f_id AND EXISTS
(select o3.Object_ID, o3.Property from t_objectproperties o3 where o2.Object_ID = o3.Object_ID and o2.Property = o3.Property
group by o3.Object_ID, o3.Property, o3.Value
having COUNT (*) > 1)
group by Object_ID , Property, Value);
end
else
begin
if @@fetch_status != 0
break
fetch prior from c1 into @l_name, @l_id, @l_guid
break
end
if @@fetch_status != 0
break
end
if @@fetch_status != 0
break
end
close c1
deallocate c1
go
_______________
View used by Script:
CREATE VIEW branch AS WITH branch (root_guid, package_id, package_name, Level) AS (SELECT t_package.ea_guid, t_package.Package_ID, t_package.Name, 0 AS Level FROM t_package UNION ALL SELECT branch.root_guid, t_package.Package_ID, t_package.Name, Level + 1 FROM t_package INNER JOIN branch ON t_package.Parent_ID = branch.package_id) SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type CLASSTYPE, branch.root_guid, branch.Level, branch.package_id, branch.package_name, t_object.name, t_object.Stereotype, t_object.Object_Type FROM t_object, branch WHERE t_object.Package_ID = branch.package_id