Datatable to Tab Delimited Text file

R

RSH

Hi,

I have a situation where I am querying SQL Server and bringing back a
Dataset. Is there a way to dump the datatable to a delimited text file
without iteration through the datatable?

The reason i need to do this is I am having to traverse a large number of
databases and the with iteration the process is taking quite a long time.

Thanks in advance!
Ron
 
A

AMDRIT

I propose that you use DTS for this activity instead.

However,

In the past, I have dumped the xml of a datatable into a stringbuilder, and
executed a series of replace statemements. Finally, I iterate over the
columnnames of the table and insert them at the beginning of the string
builder for the row header.

Hope that helps.

<Newtable>
<datarow><Column1>Blah</Column1><Column2>Blah1</Column2></datarow>
</Newtable>

becomes
"Column1","Column2"
"Blah","Blah1"
 
A

AMDRIT

There are of course other ways to go.

Instead of populating a datatable, which would be discarded anyway. Use a
DataReader and just stream the results into a text file on the fly. Perhaps
this would have the lowest impact on resources and time.
 

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

Top