And a code of conduct will absolutely make it clear that he's not welcome in the community and why, allowing the community to extricate themselves from him in a meaningful way.
It's fairly common for the troll to then start a meta-argument about the code of conduct, or, to accuse others of violating the code of conduct. Eventually the notion of "don't be an asshole" tends to win the argument, but it can take a while.
Communities have existed since the dawn of man and CoCs weren't necessary to keep idiots away. When someone is an idiot, you don't need a set of rules to identify that he's an idiot, and to have a basis to kick him out. If you 1) can't identify idiots or 2) can't kick out idiots, then you have a dysfunctional community or no teeth. CoCs can't fix a community or make you grow teeth.