Sharepoint can create knowledge bases for this, I bet their are templates available.
What I try to encourage on ad hoc queries is paste your select into the bottom of the email or onto a different sheet in an excel spreadsheet when delivering results. This way when someone says so and so ran this report for me last year, can you run it again?, you have the code right there.
Otherwise we just save queries in a folder with very long descriptive names.
A repository/knowledge base is great if people actually use them.