Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am new to sql but have to create a csv file from a sql table using all the fields, easy suggestions please.
Thanks
Posted

The obvious suggestion is to select the data, and then turn it into XML in code. Why have you been given this task, if you're 'new to SQL' ?

Any XML functionality in your database will be specific the the database you're using, so if you told us that, we might have suggestions as to getting XML from your DB directly.
 
Share this answer
 
Well, basically you might execute
SELECT * FROM <tablename>
and then transform the output with your favourite language.
:-)
 
Share this answer
 
Hi I can select all the records from the table in a query, just don't know how to put them into a csv file.
Thanks
 
Share this answer
 
Comments
Christian Graus 24-Aug-10 3:23am    
Please don't push 'answer' to comment, just like I don't push 'comment' to answer. Your question makes zero sense, what are you trying to do, and in what context ? It makes zero sense because you've asked us how to do something in SQL, which SQL does not do. SQL will return your data, it will not create a csv. As two people have told you, you have to do that with code. Until we know what language you're using, we can't help you, and even then, we'd prefer to see that you tried to do your own work before doing it for you.
If you need to do this from SQL Server without a client you can use BCP to output the data.

If you are using a client (winforms, ASP, WCF, Silverlight) then use Google, this has been solved many times.
 
Share this answer
 
Comments
HelenH5367 24-Aug-10 3:39am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900