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

T SQL Information schema?

We have a lot of data and to save time on making backups I have been tasked with creating a copy of the current database which only contains specified company codes/companies. I have been told to research into TSQL scripts, information schemas and…
user2520671
  • 83
  • 3
  • 13
0
votes
1 answer

SQLBulkCopy Oracle to SQL Guid error

Performing SqlBulkCopy to move 200k+ records from Oracle to SQL. Running into error converting a string a guid when performing WriteToServer. In Oracle the table saves the guid as nvarchar(50); SQL it's a unique identifier. The sql statement is…
gnome
  • 1,113
  • 2
  • 11
  • 19
0
votes
3 answers

SqlBulkCopy failing with String conversion issue

I have a view which generates a number of columns which I want to bulk load into another table which has identically named columns. This procedure worked fine when I was looping over the SqlDataReader and doing an insert with SqlParameters using a…
Tim Ebenezer
  • 2,714
  • 17
  • 23
0
votes
1 answer

Excel Data to new SQL Server table using C# - new table not being created?

I'm trying to copy data from Excel into a new table in SQL Server. The SQL code I'm using works in Server Manager, copying data into a newly created table & does seem to work here, except the new table doesn't appear in my Database and running the…
0
votes
3 answers

Bulk copy of SQL data from table on disk to an in-memory table

I want to periodically copy large records from a SQL server into a in-memory table. I need to put these fields I read into my own objects, not into another SQL table or flat file storage. Is a SQLBulkCopy the way forward to do this?
friartuck
  • 2,954
  • 4
  • 33
  • 67
0
votes
0 answers

SqlBulkCopy not getting RollBack

Actually,I have used SqlBulkCopy for inserting rows into my DB and I have placed transactions to the SqlBulkCopy. Now,My Scenario is that,I have a DataTable containing 500k rows and I'm trying to insert them through SqlBulkCopy. My Code : using…
RealSteel
  • 1,871
  • 3
  • 37
  • 74
0
votes
2 answers

SqlBulkCopy dbnull.value error

I am trying to insert rows from an excel file into sql server 2000 using bulkcopy. In the table there is a 'rowguid' field and its default value is set to (newid()) and cannot except null values. Also RowGUID is set to "Yes". In my code i remove…
Lucky Luke2
  • 2,056
  • 5
  • 25
  • 32
0
votes
0 answers

SqlBulkCopy with Line Feed and Carriage Return

I am using SqlBulkCopy to import Excel data to mssql. I have many rows of data in Excel with 2 columns which the content has Line Feed and Carriage Return (I understand from reading online below is true) Chr(10) == vbLF == Line Feed (LF) Chr(13) ==…
0
votes
2 answers

SqlBulkCopy problem

i use SqlBulkCopy to insert data from OleDbDataReader (contains data from xls) to mssql-2005 i have a cloumn on the OleDbDataReader that contains number stored as text (in the xls) when i look into the mssql data i see null in that column all…
eyalb
  • 2,994
  • 9
  • 43
  • 64
0
votes
1 answer

SQL Bulk copy (unicode)

i have a problem with bulk load into my database. Server throws error "String or binary data would be truncated", but my data seems to be ok. Im using UTF-16LE data file with XML format file. Thanks for your answers Here's my format…
0
votes
0 answers

HOWTO: Rollback on Oracle (ODP.NET) and SqlCe bulk operation failure

I would like to know how to: 1) rollback an oracle (odp.net) and sqlce bulk operation (insert, update, delete) if it has failed for some reason. I do not know If bulk operations (oracle and sqlce) do rollback automatically internally on any…
Willy
  • 9,848
  • 22
  • 141
  • 284
0
votes
0 answers

SqlBulkCopy Best Practice

I have a couple of questions regarding SqlBulkCopy. I need to insert a few million records to a table from my business component. I am considering the following approaches: Use SqlBulkCopy to insert data directly into the destination table.…
intangible02
  • 993
  • 1
  • 9
  • 19
0
votes
0 answers

FileUpload and BulkCopy

I have a plain text file that contains one column of numbers, and in a web client take the numbers and transfer them into a SQL Database. After retrieving the file, I store the contents in a temporary DataTable, then using SqlBulkCopy, attempt to…
Delfino
  • 967
  • 4
  • 21
  • 46
0
votes
1 answer

SQLBulkCopy - WriteToServer method not working

I'm trying to export some data from an Excel file to a MDF database. To do that, I'm using Excel Data Reader and SQL Bulk Copy : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using…
Traffy
  • 2,803
  • 15
  • 52
  • 78
0
votes
1 answer

Is it possible to ALTER TABLE (DDL) in the middle of an DML transaction on the same table?

Say, you begin a SqlTransaction from C# inside which you are inserting data from a DataTable into a SQL table, but this data is A LOT of data, so you do it 'in chunks' with a SqlBulkCopy inside the SQL transaction and only commit the transaction if…
sergeidave
  • 662
  • 4
  • 11
  • 23