Can you explain a little more in detail exactly what you are doing ?
You say the report is a T-SQL program.
Exactly what does that mean ?
Do you have a stored procedure that writes 5 million rows to a temporary table ?
Do you run a stored procedure from SSMS, return 5 million rows and then try to write them to a file from SSMS ?
Or what are you really doing ?