That won't work unless you're a soccer/basketball/whatever star and probably not even then.
He announced he was leaving our company for Amazon (which paid substantially more), and we even had a whole Friday goodbye party with cake and balloons. The next Monday we came into the office, surprised to see him still working for us. It turns out that over the weekend he somehow convinced management to match and exceed Amazon's offer.
His "trick" for getting a raise is that our whole dev-ops setup was unworkable without him. Management hadn't come up with contingencies for his inevitable departure, and thus he held all the leverage in salary negotiations.