Breaking up with sales orders can be hard to do.  You try your best to make invoicing work, but eventually you cut your losses and to part ways.  Or at least try to.  "The sales order cannot be deleted because related not posted transactions exist" error can appear for a variety of reasons; sometimes those reasons make sense, and sometimes they're confusing.  

The least common, and rarely thought of reason for this error is because there are existing invoice history records (ie invoicing demons) related to the order.  This is why even if you delete every order line (SalesLine), the error still comes up when you try to delete the empty header (SalesTable).  In lower tier environments, it's easy to delete the SalesParmTable and SalesParmLine table records with a job or script, however in a production environment you have to brush up on your navigation skills.

Accounts receivable > Inquiries and reports > Invoices > Invoice history is your path to healing.  Here you can filter on your order, delete the invoicing history, and move on with your life.