When it is necessary to have a person imprisoned in the state prison brought before any court, or a person imprisoned in a county jail brought before a court sitting in another county, an order for that purpose may be made by the court and executed by the sheriff of the county where it is made.
Idaho Code § 19-4601