Fence will solve less than half of the problem. Most illegals arrive legally on a tourist or student visa, and do not leave after visa expires.
Thats true, and thats a continuing problem that would have to be solved with enforcement. In the last several years, I don't see a lot of enforcement happening away from the border. But step one, you have to control the border. If you won't even do that, you aren't serious about anything else.
Of course, the will to enforce the law is key. If there is a will to secure the border and a will to enforce immigration and citizenship law, it is possible to do it. Where there is no will, no fence in the world will be enough.