Procedure to Remove Orphan Packages
To remove orphan packages from the SQL Server database, please follow the below
** You will need to have SA rights for these actions
1. Open SQL Server Management Studio, and use the site database of the child site cs1(SMS_CHILD).
2. Type and run the following command in the query window:
select PkgId, Name, SourceSite from SMSPackages
3. Search for the PkgID file that you want to remove.
4. Type and run the following command in the query window:
Update SMSPackages Set SourceSite='<Child Site Code>' Where PkgID= '<Package ID>'
5. The package is now set to a local package and you can delete it from within the SCCM Administrator console.
Deletion should be performed from the SCCM console instead of via the database level to ensure that the deletion is clean.