ZedZip
ZedZip

Reputation: 6510

c# How to upload multiple files to SQL Server database?

Given:

  1. c# WinForms application
  2. more than 1000 .txt, .pdf, .doc files
  3. SQL Server 2008 table

    create table docs
    (
        id int not null identity primary key,
        filename nvarchar(255),
        filecontent varbinary(MAX),
        filetype nvarchar(10),
    )
    

I know how to upload file by file using INSERT or MERGE, but it is a long operation.

How to effectively fast upload many files into the table?

Upvotes: 0

Views: 965

Answers (1)

Naveen Katakam
Naveen Katakam

Reputation: 401

use SqlBulkCopy operation so that you can insert multiple records faster.

Upvotes: 1

Related Questions