I have a project that requires me to create a script for migration between test and live data-bases.

What i want to do is create an extract from the test database into an excel sheet or a txt file located in a specified file location. 

All in script. 
Is there a query that is able to insert into an excel sheet or a txt file and save it at a specified location?