OPINION OF THE COURT
Mangano, P. J.On this appeal, we are asked to determine, inter alia, whether the defendant: (1) was deprived of the effective assistance of counsel when his attorney informed the court that the defendant intended to perjure himself on the stand and (2) was deprived of his right to be present at material stages of trial when his attorney conveyed this information during court conferences at which the defendant was not present. '
The defendant and his accomplices ransacked the home of a 71-year-old man, robbed hini, stabbed him with a knife and scissors, and bludgeoned him to death with a shovel. Upon his arrest, the defendant made various statements to the police which placed him at the scene of the crime. In addition, his fingerprints and blood were found at the scene of the crime. *62The defendant was offered a plea agreement, but chose instead to go to trial.
At the close of the People’s case, the defense counsel noted at a sidebar that he had advised the defendant that he did not have to testify but should the defendant decide to do so, he should testify truthfully. After the defense counsel informed the court that the defendant wanted to testify, the court questioned the defendant, who confirmed counsel’s statements. Thereafter, the defense counsel elicited the defendant’s direct testimony in narrative form. The defendant testified that he was home the entire evening of the crime, and that his statements to the police were induced by promises that he could return home once he gave the statements.
After both sides rested, the defense counsel addressed the court at an ex parte conference. The court then proceeded with the charge conference in the defendant’s presence. During summations, the defense counsel did not rely on the defendant’s trial testimony.
The defendant’s contention that he was deprived of the effective assistance of counsel lacks merit. It is axiomatic that “a defendant’s right to testify [at trial] does not include a right to commit perjury” (United States v Dunnigan, 507 US 87, 96). An attorney’s ethical duty to advance the interest of his or her client is circumscribed by an “equally solemn duty to comply with the law and standards of professional conduct” to “prevent and disclose frauds upon the court” (Nix v Whiteside, 475 US 157, 168-169; People v Campos, 249 AD2d 237, 238). Thus, a defendant’s Sixth Amendment right to the assistance of counsel does not include the right to compel counsel to knowingly assist or participate in the presentation of perjured testimony (see, Nix v Whiteside, supra).
Although an attorney has a duty to zealously represent his client, that duty is limited to “legitimate, lawful conduct compatible with the very nature of a trial as a search for the truth” (Nix v Whiteside, supra, at 166). These principles are consistent with those provisions of the Code of Professional Responsibility which preclude an attorney from assisting his client in presenting false evidence (see, Code of Professional Responsibility DR 4-101 [c] [3] [22 NYCRR 1200.19 (c) (3)]; Code of Professional Responsibility DR 7-102 [a] [4]; [b] [1] [22 NYCRR 1200.33 (a) (4); (b) (1)]; see also, People v Appel, 120 AD2d 319, 320-321; People v Salquerro, 107 Misc 2d 155).
In this case, the defense counsel zealously represented his client while maintaining his ethical obligations. He informed *63the defendant of his ethical obligations and, when it became apparent that the defendant would persist in giving perjured testimony, he disclosed this fact to the court in an effort to ensure that any trial procedure would safeguard the defendant’s right to testify and, simultaneously, prevent the defense counsel’s participation in the fraud (see, People v Tyler, 245 AD2d 1100; People v Salquerro, supra, at 158-159; see also, Diaz v LeFevre, 1997 US Dist LEXIS 3634, 1997 WL 150987 [SD NY, Mar. 28, 1997, Cote, J.]).
Although the defendant contends that the defense counsel should have withdrawn from the representation, that option would not have resolved the dilemma as:
“ [Substitution of* * * counsel, unaware of the possibility of perjury, may overtly facilitate, or appear to condone, a fraud upon the court. Such substitution procedures would effectively cloak the problem; however, this ostrich-like approach would do little to resolve it.
“A defendant inclined to commit perjury may find another attorney who lacks the ethical standards possessed by his present attorney, and who may readily present his client’s falsified story, or who at the very least would not impede its telling. Such a defendant may even be less candid with a new attorney and keep his perjurious intentions to himself. Alternatively, bolstered by the success of his first disclosure in postponing trial, such defendant might be equally frank with a new attorney, in order to further delay the proceedings” (People v Salquerro, 107 Misc 2d 155, 157-158, supra).
Thus, the evidence, the law, and the circumstances of the case, viewed in totality and at the time of the representation, reveal that the defense counsel provided meaningful representation (see, People v Baldi, 54 NY2d 137, 151-152; People v DeFreitas, 213 AD2d 96).
In addition, the defendant’s right to be present at a material stage of trial was not violated when the defense counsel had discussions with the court about his client’s intention to commit perjury.
The statutory and constitutional right to be present at all material stages of trial extends to ancillary proceedings when criminal defendants may have “something valuable to contribute” (People v Morales, 80 NY2d 450, 456), and their presence would have a “ ‘substantial effect on their ability to defend against the charges’ ” (People v Spotford, 85 NY2d 593, 596, quoting People v Sloan, 79 NY2d 386, 392; see also, People v Roman, 88 NY2d 18, 26; People v Sprowal, 84 NY2d 113, 118).
*64Invocation of the statutory right to be present will be rejected, however, when the claim that the defendant’s presence would have had an impact on the outcome of the trial is “speculative,” the violation of the statute is “de minimis,” or the defendant’s presence could not have afforded him any meaningful opportunity to affect the outcome of the particular proceeding at issue (People v Roman, supra, at 26, quoting People v Morales, supra, at 455, 457, n 2).
The record reveals that the defendant’s presence at the ex parte conference would not have provided him with a meaningful opportunity to affect the issue before the court, which was the propriety of the defense counsel’s past and future conduct regarding the presentation of perjured testimony to the jury (see, People v Williams, 85 NY2d 945, 947; People v Hines, 260 AD2d 646). Given that the discussions with the court were necessitated by the defendant’s insistence on peijuring himself despite being advised not to do so, the claim that his presence at these discussions would have had an impact on the outcome of the trial is also speculative, and the violation of CPL 260.20, if any, is de minimis. Accordingly, the defendant was not deprived of his right to be present at a material stage of trial.
The defendant’s remaining contention concerning his sentence lacks merit (see, People v Hladky, 229 AD2d 400; People v Beverly, 220 AD2d 881). Accordingly, the judgment is affirmed.
S. Miller, Friedmann and Feuerstein, JJ., concur.
Ordered that the judgment is affirmed.