North Carolina General Statutes
Article 8 - Habeas Corpus Ad Testificandum.
§ 17-41 - Authority to issue the writ.

17-41. Authority to issue the writ.
Every court of record has power, upon the application of any party to any suit or proceeding, civil or criminal, pending in such court, to issue a writ of habeas corpus, for the purpose of bringing before the said court any prisoner who may be detained in any jail or prison within the State, for any cause, except a prisoner under sentence for a capital felony, to be examined as a witness in such suit or proceeding in behalf of the party making the application.
Such writ of habeas corpus may be issued by any magistrate or clerk of the superior court, upon application as provided in this section, to bring any person confined in the jail or prison of the same county where such magistrate or clerk may reside, to be examined as a witness before such magistrate or clerk.
In cases where the testimony of any prisoner is needed in a proceeding before a magistrate, or a clerk, and such person is confined in a county in which such magistrate or clerk does not reside, application for habeas corpus to testify may be made to any justice or judge of the General Court of Justice. (1868-9, c. 116, ss. 37, 38; Code, ss. 1663, 1664; Rev., ss. 1855, 1856; C.S., s. 2243; 1969, c. 44, s. 43; 1971, c. 528, s. 3.)