Your SQL returns more than 1048576 rows? If so, see:
https://support.microsoft.com/en-us/kb/120596. You should be able to adapt the code there. Remember to replace the code references to 65536 with 1048576. However, that also implies your SQL data are being output to a text file from which you can import it into Excel.