How can I use a SQL query to retrieve data on a database sever?
In EXCEL, from the Data ribbon, Get External Data tab, select From Other Data Sources -> From SQL Server.

Follow the wizard to connect to your server and create a query.