SQL Script's output to a CSV file

I need to call and execute an SQL script within a KSH script and get the output/extracted data into a CSV file. Is there any way to get the out put in a CSV file other than spooling ?

I tried spooling. Problem is if there is any wrning/comment/Error they all will be spooled into the csv file. I just need pure data from DB.

This is a frequently asked question, use the Google Custom Search above, and search for:

sql csv

Regards

I have seen many posts here. all seem to explain spooling. I need any alternative method.
I have explained the probs with spooling. Plz help if anyone knows.

What is the output of the sql command and what is the desired output?

Please use code tags.

How you will eliminate the WARNING's in the SQL?? first of all..leave about spooling..

Also post the input and expected output.