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
0
votes
1 answer

SqlBulkCopy inserting null instead of Double

I'm trying to import excel files to my website then save its content in the sql server my problem with sqlbulkcopy when it fill the database some column filled with wrong values which is NULL ! while the column have a not null double values ! here…
seetah
  • 1
  • 1
  • 4
0
votes
1 answer

SqlBulkCopy with implicit truncation

Trying to insert data using SqlBulkCopy, and I get this error: Received an invalid column length from the bcp client for colid 6 They recommend one of two things: Increase varchar size in DB (to accommodate larger strings) Manually truncate the…
Nate Anderson
  • 18,334
  • 18
  • 100
  • 135
0
votes
2 answers

Using SqlBulkCopy for inserting to SQL

I don't know why data isn't getting into SQL. Can someone please review this and see what's wrong with my code? I got most of the code below from and MSDN page:…
Aaron Hurst
  • 109
  • 2
  • 3
  • 13
0
votes
1 answer

sqlbulkcopycolumnmapping import csv to table issue

I am at a loss. I am trying to import columns from a csv into an existing data table. I believe the best way to do this is through column mapping using sqlbulkcopy but i just cant wrap my head around this. Im using the script below with the…
user2402045
  • 71
  • 1
  • 3
  • 13
0
votes
1 answer

SqlBulkCopy approximate performance

I want to write a web api which should receive Excel / csv files with around 10 columns and parse and insert into a normalized SQL Server database using SqlBulkCopy (4 foreign key constraints, 2 non-clustered indexes). What will be approximate…
Imran Rizvi
  • 7,331
  • 11
  • 57
  • 101
0
votes
1 answer

Overpassing SqlBulkCopy - Violation of Primary Key

I'm trying into upload to a database records in batches of 10 using SqlBulkCopy. Some of the data already exists in the destination table so, even if one record out of ten exists, the rest fail to get uploaded as well. Is there a way to upload the…
alwaysVBNET
  • 3,150
  • 8
  • 32
  • 65
0
votes
1 answer

Validating data in my Data Table before attempting to write to the database with SQLBulkCopy

I make use of SqlBulkCopier to insert a large number of entries into our logging database. The layout of the program is: It receives a stream of data from the networks (other servers) it then parses the stream and builds up Log objects. (200 - 400)…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
0
votes
2 answers

Bulk insert into SQL table from CSV using C#

I need to bulk insert data into SQL from a csv file. In SQL I use the command: bulk insert InputTestData from 'D:\Project\UnitTestProjct\RGTestingToolTestProject\NUnitTestProject\RGTestToolDB\InputTestData.csv' with ( CODEPAGE ='RAW', …
Neeraj Dubey
  • 4,401
  • 8
  • 30
  • 49
0
votes
0 answers

Get BulkCopy Percentage for Progress Bar

I am using normal INSERT queries to write a DataTable into my database. This way I know which record is being inserted and I can tell my ProgressBar to show the progress percentage correctly. But I would like to replace my record-by-record INSERTs…
disasterkid
  • 6,948
  • 25
  • 94
  • 179
0
votes
1 answer

Table object is null after sqlbulkcopy insert

i am trying to insert data into database table using sqlBulkCopy it works fine data is inserted, then I would like to query my data but when I referenced to the updated table, I am getting error: object is null. I am able to see this table using…
0
votes
1 answer

SQL function to copy a custom field to the post_content en mass in for wordpress

I need to copy the contents of key value for the key post_content to another table called wp_posts into the key values for post_content. Is there anyway to do this in bulk, like all posts in the database? This would help me greatly, thank you.
Matt Douglas
  • 49
  • 1
  • 10
0
votes
0 answers

SQL Bulk Copy into separate Tables

I want to perform insert into database but in different Tables. Each record i have in my file is assigned with the table Identifiers which will be used as a key. For now what i have done is to make it a generic approach, I have created one more…
Abid Ali
  • 1,731
  • 8
  • 26
  • 62
0
votes
1 answer

SqlBulkCopy.WriteToServer abort, OperationAbortedException?

I'm currently running two tasks which are copying data to my SQL Server. The data copying is done by the method SqlBulkCopy.WriteToServer. I'm using the SqlRowsCopiedEvent to show the user the amount of rows that are successfully copied. Every time…
LimpSquid
  • 327
  • 6
  • 17
0
votes
2 answers

How to avoid Error "There is already an open DataReader associated with this Command" in MSSql 2000

I am using SqlBulkCopy to copy data to 2 separate table in same database. obj_Command.CommandText = "Select * from tmpInvDtlMast where InvNo='111'" Using bulkCopy As SqlBulkCopy = New SqlBulkCopy(con1) …
Sajitha Rathnayake
  • 1,688
  • 3
  • 26
  • 47
0
votes
2 answers

Delete rows from DataTable in memory matching duplicate rows in Database

I have a dataTable which I will use to BulkCopy to a destination table. I am trying to resolve primary key violation. So instead of using a temp table and then merge with production, I am trying to delete the redundant rows from the DataTable in…
FrengiX
  • 77
  • 1
  • 7