He visited Stargate Command at that time because of a "ridiculous" mission on M4C-862. Colonel Jack O'Neill seems to be rather admiring of General Ryan. Ryan appears to be on first-name terms with Major General George S. Hammond. (SG1: "Prodigy")
Behind the scenes
General Ryan was the real Chief of Staff at the time this episode aired and he portrayed himself. As stated on the featurette for volume one of Season Eight, Richard Dean Anderson asked Ryan whether there were really colonels like O'Neill, to which Ryan replied, "yes, and worse."
There is also a reference made to General Ryan in Season 5 Episode 12 "Wormhole X-Treme!" when Colonel Jack O'Neill is questioning a security guard for information on people who have arrived on set and explains that it is a security check: "One of our Generals is doing a guest spot on a show. It's a small, but pivotal role."