The church seen in the opening scene of the film is St Mary's in Harefield, Middlesex (Google Earth)
The barracks featured in Carry On Sergeant were the Queen's Barracks in Stoughton, Surrey; home to the Queen's Royal Surrey Regiment. They are now a residential development (Google Earth)
The final scene of the film, where the soldiers exit the barracks was filmed at the rear gates of Pinewood Studios (Google Earth)