Export SQL result to CSV file.