This is called doctor shopping and it can be prosecuted a criminal offense. It occurs when you withhold information from a doctor as to what other doctors you are seeing and what they have prescribed for you, so that you can get a hold of more of a particular medication than any one doctor would ever give you a lawful prescription for. Here's the law below:
Public Health Law § 3397. Fraud and deceit.
1. No person shall:
(a) obtain or attempt to obtain a controlled substance, a prescription for a controlled
substance or an official New York State prescription form,
(i) by fraud, deceit, misrepresentation or subterfuge; or
(ii) by the concealment of a material fact; or
(iii) by the use of a false name or the giving of a false address;
(b) willfully make a false statement in any prescription, order, application, report or record required by this article;
(c) falsely assume the title of, or represent himself to be a licensed manufacturer,
distributor, pharmacy, pharmacist, practitioner, researcher, approved institutional
dispenser, or other authorized person, for the purpose of obtaining a controlled substance;
(d) make or utter any false or forged prescription or false or forged written order;
(e) affix any false or forged label to a package or receptacle containing controlled
(f) imprint on or affix to any controlled substance a false or forged code number or symbol.
2. Possession of a false or forged prescription for a controlled substance by any person other than a pharmacist in the lawful pursuance of his profession shall be presumptive evidence of his intent to use the same for the purpose of illegally obtaining a controlled substance.
3. Possession of a blank official New York state prescription form by any person to whom it was not lawfully issued shall be presumptive evidence of such person's intent to use same for the purpose of illegally obtaining a controlled substance.
4. Any person who, in the course of treatment, is supplied with a controlled substance or a prescription therefor by one practitioner and who, without disclosing the fact, is supplied during such treatment with a controlled substance
or a prescription therefor by another practitioner shall be guilty of a violation of this article.
It would appear that certain prescriptions in New York MUST be filled electronically and thus would appear in a statewide data base. You can read more about this here. (see link) As far as other prescriptions the state wisely does not publish which pharmacies are non-participating and which are not.
As a general rule, if caught, the pharmacist will simply refuse to fill the subscription, send you away, and alert the doctor who will cut off that part of the supply. I can't say that a fact pattern like yours has never been prosecuted, but I can say that the ones I have seen in court involve forged prescriptions or possession of controlled substances in amounts in excess of personal use supplies.