Create csv

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.
 
A

Andy O'Neill

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
 
G

Gregory A. Beamer

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! |
************************************************
 
D

DavidC

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.
 
D

DavidC

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.
 
G

Guest

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 from an
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.
 
M

Mike Lovell

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,095
Messages
2,570,616
Members
47,232
Latest member
helpplease!

Latest Threads

Top