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
0 answers

What is the most efficient way to move bulk data from a web service that return JSON to a database table?

OK, so my situation is this: I have to call a remote webservice that returns data as a json object. I need to take this data and map it an existing table in a database. So, I need to map this data and then add it to the existing table in the most…
Kelso Sharp
  • 972
  • 8
  • 12
0
votes
1 answer

BulkCopy Error" `The given value of type String from the data source cannot be converted to type int of the specified target column.`

I am trying to import data from CSV to DataBase usingBulkUpload, I am able to copy columns which are varchar but I am not able to import when I try to import integer column. Error:The given value of type String from the data source cannot be…
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
0
votes
2 answers

Impact of existing indexes on performance of COPY FROM

After reading the PostgreSQL reference doc on COPY, I did not find how COPY deals with indexes. What exactly happens when COPYing data from a file into a table when the table already has indexes. I wonder if these indexes will be destroyed…
Fopa Léon Constantin
  • 11,863
  • 8
  • 48
  • 82
0
votes
0 answers

How to stop SqlBulkCopy.WriteToServer from attempting to use the MSDTC (Distributed Transaction Coordinator)

My code is pretty simple. I'm really not sure why this is happening. I'm not sure transaction scopes or anything. I'm just attempting to bulk copy data into my database using (SqlBulkCopy bulkCopy = new SqlBulkCopy(MyConnectionString)) { …
Mark
  • 5,223
  • 11
  • 51
  • 81
0
votes
2 answers

SqlBulkCopy - empty datarows in db2table

now I finally got to write the rows of my csv (somewhat) into the table. It does add the 7 rows of the csv, but without data. The only thing it sets is the id, but that's autoincremented anyways. The data out of the csv doesn't arrive in the table. …
OhSnap
  • 376
  • 2
  • 10
  • 30
0
votes
1 answer

SqlBulkCopy ColumnMapping Argumentexception

the following code gives me an argumentexception saying, that the sourcecolumn 'e_partnerid', which is clearly in the csv, doesn't exist. I have a feeling that the Delimiter isn't set right or something like that and I tried changing the…
OhSnap
  • 376
  • 2
  • 10
  • 30
0
votes
2 answers

DataTables In Async Methods

I have created some async methods and have been adding records to a dataTable in those methods, and then bulk copying the dataTable after the async methods are done. I've found now that dataTables are not thread-safe, and that is the source of my…
KJ3
  • 5,168
  • 4
  • 33
  • 53
0
votes
2 answers

How to implement versioning in combination with bulk insert on MSSQL?

I'm performing a bulk insert of many records (typically 100k) using .NET class SqlBulkCopy, into a MS SQL Server 2012 database. My table looks like this: CREATE TABLE [dbo].[Product]( [Id] [bigint] NOT NULL, [Name] [varchar](50) NULL, …
Mikee
  • 626
  • 1
  • 10
  • 23
0
votes
3 answers

Using the SQL bulk copy in C# and deleting the string headers

The code below is what I use for inserting the data stored in txt file to sql: public void extract_data() { openFileDialog1.ShowDialog(); DataTable dt = new DataTable(); StreamReader sr = new…
Lucas Juan
  • 351
  • 5
  • 9
  • 23
0
votes
2 answers

Database engine independent analog of SqlBulkCopy

What is the best database engine independent way to load a huge amount of data. While I'm using SQL Server I use SqlBulkCopy but want to untie from SQL Server
abatishchev
  • 98,240
  • 88
  • 296
  • 433
0
votes
2 answers

Import CSV data into SQL Server

I have data in the csv file similar to this: Name,Age,Location,Score "Bob, B",34,Boston,0 "Mike, M",76,Miami,678 "Rachel, R",17,Richmond,"1,234" While trying to BULK INSERT this data into a SQL Server table, I encountered two problems. If I use…
0
votes
2 answers

Getting Error Invalid cast from 'System.String' to 'System.Guid'

I am Importing Data in Student Record from excel sheet with .xls as it's file extension when i am calling the function to upload Excel that is public ActionResult Importexcel() { if (Request.Files["FileUpload1"].ContentLength…
Neeraj Mehta
  • 1,675
  • 2
  • 22
  • 45
0
votes
2 answers

SqlBulkCopy WriteToServer example. What am I doing wrong?

This might be long, but I want to explain my example I got this Code: #region [parent table] DataTable dtParent = new DataTable(); DataColumn dc; dc = new DataColumn(); dc.DataType = System.Type.GetType("System.Int32"); dc.ColumnName =…
Ash
  • 1,269
  • 3
  • 25
  • 49
0
votes
0 answers

BULK Collect operation failing to copy records from one table to another table

Tried below code to copy records from one table to another table, first table is process_state, second table is process_state_archive CREATE OR REPLACE PROCEDURE fast_proc (p_array_size IN PLS_INTEGER DEFAULT 100) IS TYPE ARRAY IS TABLE OF…
vkreddy
  • 181
  • 6
  • 18
0
votes
2 answers

Performance issue with SqlBulkCopy and DataTable

I need to efficiently import large amount of data from file to database. I have few rrf file which contain that data, the size of a file could be > 400mb and eventually it could be > 2 million record to database from file. What did I do: I am…
makambi
  • 1,100
  • 3
  • 13
  • 30