I found that saying that worked gradually so that I began not to think of a drink in 5 minutes. Without realising it, I didn't think of a drink for an hour, then longer. Eventually , after quite a while , I was habituated so I didn't obsessively think about it.
But, if you want to avoid temptation overcoming you, remember H. A. L. T, (Halt) !
That is: never get Hungry, never get Angry, never get Lonely, never get Tired. Anyone one of those makes you vulnerable. Two of them makes you very vulnerable. Three means it may be too late. Four means, Hell, you are taking a drink and can't work out why! Once you take that drink, you'll start again, and you can't stop. And then you are back where you started, a very frightening thought