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

What is best practice for updating server generated entity IDs after a bulk insert?

There are just under a million nodes in an object graph, mostly disconnected, that need to be imported in bulk. The keys are all server-generated. There are several levels of relations, so after each batch is inserted the correct identity keys need…
jnm2
  • 7,960
  • 5
  • 61
  • 99
0
votes
0 answers

Saving with ADO.NET

It is probably really easy for you but i'm a beginner and I don't find how to save the mofifications in my database after an bulkcopy. The situation i'm trying to import a .csv file into my database using this code : Public Sub ImportCSV2SQL(ByVal…
Rave
  • 197
  • 2
  • 15
0
votes
0 answers

How to make condition in SqlBulkCopy?

I'm using SqlBulkCopy in order to copy a datatable into a database table, because the data is over 250,000 rows. But I am facing a problem. I need to make condition for the process of copying data. For example If The Code Equal '1111' then don't…
ahmed mohamady
  • 293
  • 1
  • 7
  • 30
0
votes
2 answers

DateTime saved as numeric value using SqlBulkCopy

I'm using SqlBulkCopy to save a read-only Excel sheet into a predefined SQL table. There are several date columns in the sheet, but not all the rows have date values(empty and '#'). The corresponding columns types are varchar(20) and not…
Yevgeni Grinberg
  • 359
  • 5
  • 19
0
votes
1 answer

Bulk insert between tables in same database

Fastest way to do insert in a table A with same structure of a table B: INSERT INTO A SELECT * FROM B I can't rename table because in table A there are indexes that when query is executed it's impossible to know without read catalog and create a…
Luigi Saggese
  • 5,299
  • 3
  • 43
  • 94
0
votes
4 answers

Converting String to bit before inserting into the database

Can anyone help in converting string value in C# to bit equivalent in Sql. I'm trying to bulkcopy the values of a datatable into Sql table. All the values I've in the datatable are in string format. When I try to bulkcopy to SQL table I'm getting…
vix
  • 1
  • 1
  • 1
  • 1
0
votes
0 answers

Inserting in memory objects (datatable) to database by SSIS Packages

In Sql Server 2008, I need to create a large data mart. I've written .NET Code (C#) for running all SELECT Stored Procs in parallel from code and join the results in datatable in memory. I insert the datatable to database by SqlBulkCopy, but it gets…
Ahmet Altun
  • 3,910
  • 9
  • 39
  • 64
0
votes
0 answers

SQL Server Bulk Insert (VB.Net)

I would like to use sqlbulkcopy to move values from a csv file into sql server. The problem I have is that the csv is double quoted and comma delimited. I believe that sqlbulkcopy won't work with double quotes from code behind as a delimiter. Does…
MonkeyDoug
  • 453
  • 3
  • 17
0
votes
0 answers

Empty Strings, Nulls, and Money types with SqlBulkCopy

I have some TAB delimited text files that I have to import to a SQL Server each month using an ASP.NET intranet page. I have been using the Generic Parser found here to import the files to DataTables and then SqlBulkCopy with column mapping to copy…
techturtle
  • 2,519
  • 5
  • 28
  • 54
0
votes
3 answers

Which right grants user a right to grant another right to himself in SQL 2008?

I need to grant a db_datawriter before executing SqlBulkCopy and remove it after: try { "EXEC [db_mod].[sys].[sp_addrolemember] N'db_datawriter', N'my_user'" // via SqlCommand bulk.WriteToServer(table); } finally { "EXEC…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
0
votes
1 answer

Is it possible to use SqlBulkCopy in SQL 2008 without permission 'db_datawriter'?

I want to limit my database possible access ways to only using stored procedures. Everything works fine except System.Data.SqlClient.SqlBulkCopy. I'm using it only in one class for massive data import. Is it possible to avoid this problem? I tried…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
0
votes
0 answers

Using SqlBulkCopy SqlRowsCopied to update a label

I have a simple web application that is reading records from a CSV file and storing them in a database table. Then I am using SqlBulkCopy to copy the records into an SQL database using batches. All is fine with the insert. I am trying to give the…
gonzo193
  • 11
  • 2
0
votes
5 answers

Bulk Copy from SQL Server to Oracle

I have a requirement for a project to move data from SQL Server to Oracle in bulk mode. There is OracleBulkCopy from DataDirect and ODP .net but to use that I have to first convert the data reader from SQL server into a CSV file and then can export…
Manav
  • 1
  • 1
  • 1
0
votes
1 answer

SqlBulkCopy and File Archiving

I have a process that loads data into a sql table from a flat file then needs to immediately move the file to an archive folder. However when running the code it imports the data but throws and IOException {"The process cannot access the file…
0
votes
1 answer

Best method to copy a file to the SQL Server machine

I am looking into copying a file from the client computer to the server computer. One path I've looked into was creating a CLR method which accepts a stream as input. Another suggestion I've had is to use the BCP utility, though I have been…
Luke G
  • 367
  • 1
  • 4
  • 20