
893 So.2d 303 (2004)
Ex parte Talladega County Deputy Sheriff Jason Lowell BLANKENSHIP and the Talladega County Commission.
(In re Lavone P. Higginbotham, individually and as personal representative of the estate of Charles E. Higginbotham, deceased,
v.
Jason Lowell Blankenship, an individual, and the Talladega County Commission, a political subdivision, et al.)
1030484.
Supreme Court of Alabama.
May 7, 2004.
*304 George W. Royer, Jr., of Lanier Ford Shaver & Payne, P.C., Huntsville; and Barry D. Vaughn of Proctor & Vaughn, Sylacauga, for petitioners.
Robert Rumsey of Rumsey & Wilkins, Sylacauga, for respondent.
Kendrick E. Webb and Bart Harmon of Webb & Eley, P.C., Montgomery, for amicus curiae Association of County Commissions of Alabama, in support of the petitioner Talladega County Commission.
J. Jeffery Rich of Sirote & Permutt, P.C., Huntsville, for amici curiae Madison County Sheriff Blake Dorning and Madison County, in support of the petitioners.
WOODALL, Justice.
Talladega County Deputy Sheriff Jason Lowell Blankenship and the Talladega County Commission ("the County") petition this Court for a writ of mandamus, directing the Talladega Circuit Court to dismiss the action brought against them by Lavone P. Higginbotham, individually and as the personal representative of the estate of Charles E. Higginbotham, deceased, seeking damages for personal injuries arising out of an automobile accident involving a vehicle driven by Charles E. Higginbotham and a vehicle driven by Deputy Blankenship. We grant the petition.
The complaint in this action was filed on October 17, 2003. It averred, in pertinent part:
"3. Defendant, Jason Lowell Blankenship, is over the age of nineteen years and is a resident of Talladega, Alabama, and is a Deputy Sheriff with the Talladega County Sheriff's Department.

"....

*305 "6. Plaintiffs aver that on or about October 17, 2002, Plaintiff, Charles E. Higginbotham, was driving his vehicle on U.S. Highway 280, in Sylacauga, Alabama, near the intersection of James B. Payton Boulevard.
"7. That at said time and place, Defendant Jason Lowell Blankenship, was performing his duties as a Deputy Sheriff for the Talladega County Commission and/or Talladega County.
"8. That at said time and place, the vehicle driven by Defendant Jason Lowell Blankenship, negligently and/or wantonly, was allowed to crash into, upon, and against the vehicle operated by Charles E. Higginbotham.
"9. The Plaintiff, Lavone P. Higginbotham was a passenger in the vehicle operated by Charles E. Higginbotham."
(Emphasis added.)
Deputy Blankenship and the County filed a joint motion to dismiss on the ground, among others, that they were "entitled to absolute immunity." The trial court denied the motion. Deputy Blankenship and the County then jointly answered the complaint, admitting the allegations of paragraphs three and seven. Subsequently, they filed this petition, "request[ing] that [this] Court enter an order granting their petition and directing the circuit court to vacate its order denying their motion[] to dismiss and to enter an order granting their motion[] to dismiss ... this action." Higginbotham concedes that the claims against the County are due to be dismissed. Thus, we address only the arguments regarding the viability of the claims against Deputy Blankenship.
Deputy Blankenship argues that he "has absolute immunity under Article I, § 14 of the Alabama Constitution of 1901, from the claims alleged against him in the complaint." Petition, at 6.
It is well established that mandamus will lie to compel the dismissal of a claim that is barred by the doctrine of sovereign immunity. Ex parte McWhorter, 880 So.2d 1116, 1117 (Ala.2003); Ex parte Alabama Dep't of Mental Health & Mental Retardation, 837 So.2d 808, 810 (Ala.2002); Ex parte Butts, 775 So.2d 173, 176 (Ala.2000); see also Ex parte Haralson, 871 So.2d 802, 804 (Ala.2003). Where it is undisputed that a deputy sheriff is "acting within the line and scope of his employment ... at the time [he is involved in an automobile] accident" with the plaintiff, § 14, Ala. Const.1901, bars an action against the deputy sheriff for damages arising out of the accident. Ex parte McWhorter, 880 So.2d at 1117. This is so, because an action against a sheriff  or a deputy sheriff  for damages arising out of the performance of his duties is "`essentially a suit against the state.'" Parker v. Amerson, 519 So.2d 442, 445 (Ala.1987) (quoting Montiel v. Holcombe, 240 Ala. 352, 354, 199 So. 245, 245 (1940)); accord Drain v. Odom, 631 So.2d 971, 972 (Ala.1994) ("deputy sheriffs are immune to the same extent as sheriffs").
Here, it is alleged in the complaint and admitted in the answer that Deputy Blankenship was acting in the line and scope of his duties at the time of the accident. Of course, in reviewing a motion to dismiss, the Court "`must accept the allegations of the complaint as true.'" Ex parte Alabama Dep't of Youth Servs., 880 So.2d 393, 397 (Ala.2003) (emphasis added) (quoting Creola Land Dev., Inc. v. Bentbrooke Housing, L.L.C., 828 So.2d 285, 288 (Ala.2002)). Thus, an action against Deputy Blankenship based on this complaint is barred by § 14, and the trial court erred in denying the motion to dismiss.
*306 Higginbotham makes the unusual argument that this Court should disregard paragraph seven of her complaint and allow the action to proceed. She characterizes the allegation in paragraph seven as poor draftsmanship (response to the petition, at 21) and contends that she does not know whether Deputy Blankenship "was `performing his duties as a Deputy Sheriff' at the time of the accident." Id. at 3. She insists that paragraph seven is merely a "conclusory allegation" that should be ignored in reviewing the denial of a motion to dismiss. Id.
Although she has found no Alabama authority for her argument, Higginbotham cites a number of federal cases. Those cases, however, stand only for the general proposition that courts are not "required to accept as true allegations that are merely conclusory, unwarranted deductions of fact, or unreasonable inferences." Sprewell v. Golden State Warriors, 266 F.3d 979, 988 (9th Cir.2001). None of the authority on which Higginbotham relies stands for the proposition that a court, in considering a motion to dismiss, may simply disregard factual allegations in a complaint in order to eliminate an impediment to a claim, so that the case may go forward.
On the contrary, "[i]t is a `well-settled rule that a party is bound by what it states in its pleadings.'" Help At Home, Inc. v. Medical Capital, L.L.C., 260 F.3d 748, 753 (7th Cir.2001); Lucas v. Burnley, 879 F.2d 1240, 1242 (4th Cir.1989); Best Canvas Prods. & Supplies, Inc. v. Ploof Truck Lines, Inc., 713 F.2d 618, 621 (11th Cir.1983). Thus, "a plaintiff can ... plead himself out of a claim by including unnecessary details contrary to his claims." Sprewell, 266 F.3d at 988 (emphasis added) (citing Steckman v. Hart Brewing, Inc., 143 F.3d 1293 (9th Cir.1998)). See also Soo Line R.R. v. St. Louis Southwestern Ry., 125 F.3d 481, 483 (7th Cir.1997) ("A plaintiff can `plead himself out of court by alleging facts which show that he has no claim, even though he was not required to allege those facts.'"); Fraternal Order of Police, Strawberry Lodge No. 40 v. Entrekin, 294 Ala. 201, 212, 314 So.2d 663, 673 (1975) ("`The pleader must be careful not to allege facts that constitute a defense to his claim for relief, or, for that matter, a defense to his defense.'")(quoting 2A Moore's Federal Practice ¶ 8.02).
In effect, Higginbotham urges this Court to amend her complaint by striking paragraph seven, in order to eliminate the jurisdictional impediment that paragraph presents to her claim. We decline to do so. In order to state a cause of action for damages arising out of an automobile accident, she need not have pleaded that Jason Blankenship was a deputy sheriff acting within the line and scope of his duties at the time of the accident. Having done so, however, she cannot avoid the legal consequences of those factual allegations.[1]
Higginbotham next argues that if a writ of mandamus issues, it should direct the trial court to allow her to amend her complaint to omit the allegations in paragraph seven. We may not do so. Because the complaint purported to effect an action against the State in violation of § 14, Ala. Const.1901, the trial court acquired no *307 subject-matter jurisdiction over this action. "`Lacking subject matter jurisdiction [a court] may take no action other than to exercise its power to dismiss the action.... Any other action taken by a court lacking subject matter jurisdiction is null and void.'" State v. Property at 2018 Rainbow Drive, 740 So.2d 1025, 1029 (Ala.1999) (quoting Beach v. Director of Revenue, 934 S.W.2d 315, 318 (Mo.Ct.App.1996)). Neither this Court nor the trial court has jurisdiction to hold this action in abeyance, as Higginbotham requests.
In summary, the trial court erred in denying the motion to dismiss filed by Deputy Blankenship and the County. Consequently, we grant the petition for a writ of mandamus and direct the Talladega Circuit Court to vacate its order denying the motion to dismiss and to enter an order dismissing the action for lack of subject-matter jurisdiction.
PETITION GRANTED; WRIT ISSUED.
HOUSTON, SEE, LYONS, BROWN, JOHNSTONE, HARWOOD, and STUART, JJ., concur.
NOTES
[1]  This result is not inconsistent with Ex parte Haralson, 853 So.2d 928 (Ala.2003), in which this Court denied a petition for a writ of mandamus filed after the trial court denied a deputy sheriff's motion to dismiss claims against him for damages resulting from injuries sustained in an automobile accident. Unlike this case, Haralson involved no allegations by the plaintiff that the accident occurred while the deputy sheriff was acting in the line and scope of his official duties.
