Consider Ampere’s Law, which is given as ∮ B.dl = μ0Ienc.
Due to symmetry, the magnetic field at any point which lies on line CD will be equal, and so is with line AB.
Let the magnetic field on line AB be B2 and that on line CD be B1, according to Ampere’ law, for loop ACDB, B2l−B1l = μ0NI →B1l = B2l −μ0NI.
Now, if we extend the lines BD and AC to infinity, we will get another loop and then we will have B1l = Binfinityl − μ0NI.
From here, we can say that the magnetic field just outside the solenoid and at infinity will be the same. As you know that the magnetic field is inversely proportional to the distance, it will be zero at infinity and so will it be just outside the solenoid.
For, a solenoid, Ampere’s law will be B1 = Binside = −μ0NI/l = μ0nI, where n=Nl is the number of turns per metre. The negative sign indicates that the magnetic field will be in the opposite direction, and hence we can ignore it.
Binside = μ0nI.
⇒ I = Binside μ0n. Substituting the values, we get,
∴I = (20×10−3)/(4π×10−7)(20×102)≈8.0A
Therefore, the current necessity to produce a magnetic field of 20mT inside the solenoid will be 8.0A.