This question already has an answer here:
I am traveling to Greece. I will be traveling from New York JFK. I have a 15-hour long layover in Madrid, Spain, which is a part of the Schengen area.
I would like to know if can go out of the airport, showing my Schengen visa, and come back later to catch my connecting flight to Greece.