Neither stock barrel will fit in your G23. (Standard G19 9mm barrels are smaller in diameter than .40 barrels and G17/G22 barrels have a different bottom locking lug.) To convert your G23 to 9mm you will need a special aftermarket conversion barrel. They are available from KKM, Lone Wolf, and several other internet dealers.
I have a KKM barrel that feeds 100% in my G23 (with 9mm magazines). I recommend them highly.