ns12345
ns12345

Reputation: 3105

Loading text stream from c# to sql server without saving physical file?

I have a text stream that I can save as a txt file and then call sql server stored proc to bulkinsert that txt file.

But I don't want to deal with file system access and all that stuff. and sqlBulkCopy can't do it I beleive. What's the solution then?

Upvotes: 2

Views: 461

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062600

If the incoming stream represents rows for a table, then you can write a custom IDataReader implementation that reads from the stream and presents each row in turn (non-buffered). You can then feed this to SqlBulkCopy.

Example: https://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/b1d70b504cdee2ad?hl=en&pli=1

Upvotes: 3

Related Questions