I have already created few read-only offline maps for just read only purpose. When we create a offline maps, it does create replications in geodatabase. when users download the offline maps from devices, it does create a replica and few orphaned records got inserted in sde.sde_versions table. the records are not being deleted even though we unregistered the replicas and deleted offline maps from the devices. in order to compress the database, we should delete orphaned records and unregister the replicas. I have already written a python job to automate this process. I am able to unregister the replicas successfully without any issue, the problem is with deleting records from sde_versions table,
sde_conn = arcpy.ArcSDESQLExecute(gdb_conn)
sql_query = "DELETE FROM sde.sde_versions WHERE name LIKE 'SYNC_%'"
sde_conn.execute(sql_query)
even though the statement executed successfully, the records are still exists in the table. Please suggest on this to proceed further.