If a judgment is rendered upon any instrument in writing in which two or more persons are severally bound, and it appears to the court that a person signed the same as surety or bail for that person's codefendant, the court shall state which of the defendants is principal debtor and which is surety or bail. Execution issued on the judgment must command the sheriff to cause the property of the principal debtor to be sold and if the proceeds from that sale are insufficient, to collect the deficiency from the property of the surety or bail. The property of the principal debtor within the jurisdiction of the court must be exhausted before any of the property of the surety or bail may be taken in execution.
N.D.C.C. § 28-21-17