Create csv

  • Thread starter Thread starter DavidC
  • Start date Start date
D

DavidC

Is there an easy way in asp.net to dump out a comma-delimited file from an
SQL view or stored proc? Thanks.
 
Well there's a couple ways.

As a one off you could cut and paste into access and export the table.
Maybe excel as well.

Programmatically.
Depends how experienced you are with ssis whether you count it as "easy".
google ssis csv export
 
DavidC said:
Is there an easy way in asp.net to dump out a comma-delimited file from an
SQL view or stored proc? Thanks.

1. Open SQL Server Business Intelligence Studio (Visual Studio branded
differently)
2. Create SSIS package
3. Begin point = SQL Server view
4. End point = CSV file

That is the easiest way and you can programmatically call it for
repeatability.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
Greg,
How would I execute this package from asp.net? Would I have concerns about
user validation? We are using impersonation in web.config Thanks.
 
I should also add that I want the result to be a .csv file saved on the file
system in a virtual directory I created in our site with write capabilities.
 
I should also add that I want the result to be a .csv file saved on the file
system in a virtual directory I created in our site with write capabilities.
--
David



DavidC said:
Is there an easy way in asp.net to dump out a comma-delimited file froman
SQL view or stored proc?  Thanks.

So, then instead of my example with Response, you should create a text
file and save it in the directory. Let me know if you need an example.
 
I should also add that I want the result to be a .csv file saved on the
file
system in a virtual directory I created in our site with write
capabilities.

As Alexey says, instead of writing your CSV to the response stream, you can
just save the text to a file.

Use the System.IO namespace, you can just use File.WriteAllText(<filename>,
<data>)

You could get the data using LINQ to SQL and just format it on the fly.
That's probably the route I'd take.
 
Back
Top