Questions tagged [sqlbulkcopy]

Lets you efficiently bulk load a SQL Server table with data from another source.

The SqlBulkCopy class can be used to write data only to SQL Server tables. But the data source is not limited to SQL Server; any data source can be used, as long as the data can be loaded to a DataTable instance or read with a IDataReader instance.

Using the SqlBulkCopy class, you can perform:

  • A single bulk copy operation
  • List item Multiple bulk copy operations
  • List item A bulk copy operation within a transaction

Link to Microsoft Help Documentation: Microsoft SqlBulkCopy Documentation

964 questions
7
votes
2 answers

SqlBulkCopy - The given ColumnName does not match up with any column in the source or destination

I'm trying to use SqlBulkCopy to copy data into an SQL database table however it is (wrongly) saying that the columns don't match. They do match. If I use a breakpoint to see the names of the columns being mapped, they're correct. The error message…
PorkSausages
  • 115
  • 1
  • 1
  • 8
7
votes
2 answers

Bulk insert strategy from c# to SQL Server

In our current project, customers will send collection of a complex/nested messages to our system. Frequency of these messages are approx. 1000-2000 msg/per seconds. These complex objects contains the transaction data (to be added) as well as…
Pragmatic
  • 3,093
  • 4
  • 33
  • 62
7
votes
7 answers

SqlBulkCopy slow as molasses

I'm looking for the fastest way to load bulk data via c#. I have this script that does the job but slow. I read testimonies that SqlBulkCopy is the fastest. 1000 records 2.5 seconds. files contain anywhere near 5000 records to 250k What are some…
Chris Hayes
  • 3,876
  • 7
  • 42
  • 72
7
votes
2 answers

Cannot SQLBulkCopy Error 40197 with %d code of 4815 (Connection Forcibly Closed)

Developing with VS 2013 ASP.NET MVC 5 Web Project and Separate Azure hosted SQL Server database. At the bottom is all my error information from Visual Studio 2013. I've narrowed down the problem and found a link to the Microsoft Description of the…
John
  • 1,459
  • 4
  • 21
  • 45
7
votes
2 answers

"ERROR: extra data after last expected column" when using PostgreSQL COPY

Please bear with me as this is my first post. I'm trying to run the COPY command in PostgreSQL-9.2 to add a tab delimited table from a .txt file to a PostgreSQL database such as: COPY raw_data FROM '/home/Projects/TestData/raw_data.txt' WITH…
dnak
  • 138
  • 1
  • 1
  • 9
7
votes
3 answers

SQL Server Column names case sensitivity

The DB I use has French_CI_AS collation (CI should stand for Case-Insensitive) but is case-sensitive anyway. I'm trying to understand why. The reason I assert this is that bulk inserts with a 'GIVEN' case setup fail, but they succeed with another…
6
votes
2 answers

php postgresql pdo copy from stdin

COPY table_name ( field1, field2, field3) FROM STDIN CSV; 1,2,"q w" 3,4,"a s" 5,6,d \. How to execute this query by PDO ? Update: Problem is PDO driver executes this query as statement. For example, if you paste it into pgAdmin, it throws an…
cetver
  • 11,279
  • 5
  • 36
  • 56
6
votes
2 answers

Timeout exception even after setting timeout property for operation

Timeout issue: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.\r\nThe the statement has been terminated. I am having 17 millions of records to dump in my application database.These…
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
6
votes
3 answers

SQL Server index behaviour when doing bulk insert

I have an application that inserts multiple rows at once into SQL Server. I use either SqlBulkCopy class or self-written code that generates a gigantic insert into table_name(...) values (...) statement. My table has several indexes and a clustered…
chester89
  • 8,328
  • 17
  • 68
  • 113
6
votes
2 answers

Can SqlBulkCopy create a table from a Sql selection

Can SqlBulkCopy create a table, kind of like a SELECT INTO?
BK.
  • 365
  • 4
  • 13
6
votes
1 answer

Is SqlBulkCopy still faster than Dapper?

I found an article by Sam Saffron on bulk inserting with Dapper (That annoying insert problem getting data into the db using dapper) where he ends the article with the statement: For example, if you need an ultra fast way to insert lots of stuff…
toadflakz
  • 7,764
  • 1
  • 27
  • 40
6
votes
3 answers

SQL Server - can't import value 0 or 1 to bit column

This seems like a duplicate question. But as I searched & viewed the related questions & answers, i still can't find the answer. I am writing a loader program which imports data records from CSV file to a database table. Here is the demo. The…
Yang You
  • 2,618
  • 1
  • 25
  • 32
6
votes
2 answers

SqlBulkCopy and protection from SQL injection

I need to insert multiple rows at the same time (1000 rows) into a SQL Server database. I think best way is to use SqlBulkCopy but I'm not sure how to parametrize insert queries to be safe from SQL injection. Can you please help me? What is best…
user2980426
  • 799
  • 5
  • 8
6
votes
4 answers

Fastmember exception: Specified argument was out of the range of valid values. Parameter name: name

I've been encountering this error Specified argument was out of the range of valid values. Parameter name: name When im almost just copying the example here https://code.google.com/p/fast-member/ The error happens on the bcp.WriteToServer(reader),…
user1465073
  • 315
  • 8
  • 22
6
votes
2 answers

SqlBulkCopy to temporary table in SqlServer 2008

i need to move a large amount of data to a sql server 2008 database. I get data from a source server and write using SqlBulkCopy to destination server. this data have to be parsed from a stored procedure and then deleted. I'd like to create a…
FDB
  • 971
  • 16
  • 32