Click here to Skip to main content
15,877,246 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have database in sql server , and i have project that plot data in chart but use CSV files to plot this data ..

i want to convert SQL data in CSV format ..to plot it in chart

i use C# ,ASP.NET,SQL SERVER 2008
Posted
Comments
Ankur\m/ 4-Mar-14 3:56am    
You can write a simple query to return data in CSV. Something like -
SELECT Column1, ',', Column2 FROM TableName
phil.o 4-Mar-14 4:21am    
What have you tried? Where are you stuck?

Please refer the following link
 
Share this answer
 
Comments
Mohamed Abdelwahab 6-Mar-14 9:35am    
yeah i use it and update

using (StreamWriter writer = new StreamWriter(Server.MapPath("~/dump.csv")))
{
Rfc4180Writer.WriteDataTable(sourceTable, writer, false);
}

many thanks
SQL
SELECT DISTINCT [col1], [col2],
[col3] = STUFF ((SELECT ', ' + [col3] FROM tbl_abc b
WHERE b.col1 = a.col1 FOR XML PATH('')), 1,2,'') 
FROM tbl_abc a
 
Share this answer
 

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