FRICK, J.In the complaint it is alleged in substance, that Asenath Chadwick had obtained a judgment against the appellant *205and one A. C. Emert for $221.50, which, at the time of filing the complaint, was in full force as appeared from the records of the district court of TJintah County, TJtah; that on a day named said Chadwick caused an execution to be issued on said judgment out of said court and placed the same in the hands of the defendant, as sheriff of said county, with directions that he collect the amount aforesaid, as by said execution commanded; that the plaintiff also has a judgment against the said Asenath Chadwick, in the court aforesaid, for the sum of $363.67, which is in full force and effect. The complaint contains many other allegations of fact which are unnecessary to state. Prom all the allegations, however, it is made to appear that said Asenath Chadwick is further indebted to the plaintiff and that she is insolvent, and that therefore the defendant sheriff should be restrained from satisfying said execution, and that the judgment of the plaintiff should be offset against the judgment of said Chadwick. The defendant sheriff appeared and demurred generally to the complaint. TJpon a hearing on the demurrer the district court sustained the same, and, the plaintiff electing to stand upon the allegations of his complaint, the court entered judgment dismissing the action. Appellant assigns the ruling of the court as error.
It is not dear upon what ground the court based its ruling, but we assume that the demurrer was sustained upon the ground that the complaint did not state facts sufficient to constitute a cause of action against the defendant sheriff. If the demurrer had been based upon the ground of a defect of parties defendant, it should undoubtedly have been sustained. The demurrer, however, was general, and 1 thus could only reach defects of substance. We are of the opinion, however, that the complaint, in so far as the defendant sheriff was concerned, was defective in matters of substance, as well as in not making the judgment creditor, Asenath Chadwick, a party defendant to the action. The defendant sheriff was the mere instrument or agent of Asenath Chadwick through whom the lawi required' her to act in attempting to collect the amount due upon the exe *206cution issued upon her judgment. The plaintiff stated no facts constituting a cause of action against the defendant sheriff. It certainly cannot be contended' that, because a complaint states a good cause of action against the real party in interest, it therefore states a good cause of ’action against another who is made, and who may be, a 2 necessary party defendant to the action. Nor can it be doubted that, in an action by which it is sought to enjoin the collection of a judgment, the judgment creditor, or his legal representative, is a necessary party. We know of no rule of law or practice which authorizes a court to pass upon the legal rights of any person without mating him a party to the action or proceeding by which it is attempted to pass upon such rights. While, ordinarily, the objection that there is a defect of parties must be taken by spe- 3 cial, and not by general, demurrer, where the defect appears from the face of the complaint, yet there, as in this case, the complaint also fails to state a cause of action against the only party to the action, it cannot constitute prejudicial error to sustain a general demurrer to the com- 4 plaint, .although a good cause of action is stated therein against one not a party to the action. In view, therefore, that the complaint did not state a cause of action against the only defendant to1 the action, the court did not err in sustaining the general demurrer.
The judgment, therefore, should be, and it accordingly is, affirmed, with costs to respondent.
STEAUP, C. J., and MeCAETY, J., concur.