How to identify and delete orphan relationshipsDescription<!-- div.margin { padding: 10px 40px 40px 30px; } table.tocTable { border: 1px solid; border-color: #e0e0e0; background-color: #fff; } .title { color: #d1232b; font-weight: normal; font-size: 28px; } h1 { color: #d1232b; font-weight: normal; font-size: 21px; margin-bottom: 5px; border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: #cccccc; } h2 { color: #646464; font-weight: bold; font-size: 18px; } h3 { color: #000000; font-weight: bold; font-size: 16px; } h4 { color: #666666; font-weight: bold; font-size: 15px; } h5 { color: #000000; font-weight: bold; font-size: 13px; } h6 { color: #000000; font-weight: bold; font-size:14px; } ul, ol { margin-left: 0; list-style-position: outside; } --> Description How to count and delete orphan relationships (cmdb_rel_ci)? Procedure Here is the script can be used to find the orphan relationship counts: // Find orphan rel countvar ga = new GlideAggregate('cmdb_rel_ci');ga.addEncodedQuery('parent.sys_class_path=NULL^ORchild.sys_class_path=NULL');ga.addAggregate('COUNT');ga.query();ga.next();gs.log(ga.getAggregate('COUNT')); To delete orphan relationship //delete orphansvar gr = new GlideRecord('cmdb_rel_ci');gr.addEncodedQuery('parent.sys_class_path=NULL^ORchild.sys_class_path=NULL');//gr.deleteMultiple(); //uncheck when required.