Click here to Skip to main content
15,914,594 members
Everything / SqlBulkCopy

SqlBulkCopy

SqlBulkCopy

Great Reads

by Aadhar Joshi
Creating job in sql server which automates taking backup of all stored procedures and functions in physical drive.
by Yuriy Magurdumov
Two flavors of IDataReader implementations used together with SqlBulkCopy to insert static and dynamic data structures into SQL Server table.
by Veronica S. Zotali
How to BulkLoad a file with millions of records
by Vikash Kumar
SQL bulk copy with strongly typed data including validation.

Latest Articles

by Yuriy Magurdumov
Two flavors of IDataReader implementations used together with SqlBulkCopy to insert static and dynamic data structures into SQL Server table.
by Veronica S. Zotali
How to BulkLoad a file with millions of records
by Vikash Kumar
SQL bulk copy with strongly typed data including validation.
by sachin bankar
How to use the result set from a Stored Procedure in a Select statement.

All Articles

Sort by Score

SqlBulkCopy 

27 Nov 2012 by Aadhar Joshi
Creating job in sql server which automates taking backup of all stored procedures and functions in physical drive.
15 Jan 2014 by sameer4feb
Hi,I am using SqlBulkCopy class to insert data into table. I observed that few strings with special characters are not getting converted properly.E.g. 'hollister 香港分店地址 ' is when iserted into table using SqlBulkCopy class gets converted into 'hollister ??????' .Do i need...
7 Dec 2017 by Anuj Mehta
conString = string.Format(conString, excelPath); using (OleDbConnection excel_con = new OleDbConnection(conString)) { excel_con.Open(); string sheet1 = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0]["TABLE_NAME"].ToString(); ...
29 Sep 2020 by Sandeep Mewara
You need to set the value as DBNull. Quote: If a database field has missing data, you can use the DBNull.Value property to explicitly assign a DBNull object value to the field. Refer: DBNull.Value Field (System) | Microsoft Docs[^] Example:...
17 Jun 2023 by Mike Hankey
See this article Space in the column’s name[^] You might need to put the column name in brackets like below; use DemoDatabase go /*Query with square bracket*/ select [country code], [country name] from tblCountries Go /*Query with double...
14 Mar 2013 by tipu khan jan
Hello Guys!I want to Bulk Copy a .CSV file and save it to db. Everything is going fine but the problem I am facing is that the data of one of the column gets slightly changed. A value of "SS13" becomes "13.0000" after it is copied. Please help me to fix it friends.Here is my code .....
13 Mar 2013 by Espen Harlinn
You might be interested in the TextFieldParser[^]using (TextFieldParser parser = new TextFieldParser(filename)){ parser.CommentTokens = new string[] { "#" }; parser.SetDelimiters(new string[] { ";" }); parser.HasFieldsEnclosedInQuotes = true; // Skip the header ...
17 Dec 2013 by SwarupDChavan
The column studentId should be the identity column in your table I guess.Here is a what I did to solve this .Just map the columns that you need to insert like below SqlBulkCopyColumnMapping mapID = new SqlBulkCopyColumnMapping("CUSTOMER", "CUSTOMER");...
23 Jun 2014 by RBajania
Hi All,I want to import thousands of record from a csv file and same time I also need to manage parent child relationship for Inserting Data in tables.I have used SQLBulkCopy to Import data, and in terms of performance its fast.But I am not able to manage parent child Relationship for...
23 Jun 2014 by Thava Rajan
Then you have to try some thing Like SSIS(SQL Server Integration services) Google it you have lot info you will get for your solution
25 Sep 2014 by prateek337
Hi everyone , i m trying to do as :1 > select top 1000 records (path of a html file) from sql.2 > loop on sql result calling a thread for each row.3 > my thread is calling a regex function passing arguments from selected rows.4 > regex function is searching the href link from html file...
18 Dec 2014 by Member 11322691
If I use the below code, it does a bulk insert.string sexcelconnectionstring = @"provider=microsoft.jet.oledb.4.0;data source=" + excelfilepath + ";extended properties=" + "\"excel 8.0;hdr=yes;\"";string ssqlconnectionstring =...
4 Feb 2015 by Member 11377180
im selecting rows from gridview and on clicking a button it must copy data to datatable. in database rows are getting incremented i used breakpoints and checked the values..they are same as getting copied to database. int fields store 0, datetime fields store 01-01-0001 value, and string fields...
7 Dec 2017 by peskandritsa2
Hello fellow developers ! I'm facing an issue where i need to insert a Datatable of 1000000 rows (and there are many of these in CSV files) into SQL server. I'm using SqlBulkCopy for the job. The issue I'm facing is that one of the fields in the DataTable object, that is of type string can...
6 Dec 2017 by CHill60
If you need to use text fields greater than nvarchar(MAX) try using ntext or text[^]. You may also need to refer to Bulk Copying Text and Image Data[^] Alternatively, consider that you might want to store that text as a physical file on the server and only the path to it on the database (this...
7 Dec 2017 by peskandritsa2
I found a work around for it, It seems that SqlBulkCopy has a limitation there (I wish I'm wrong), regarding the field length. What I did was to gather all the lengthy records (after a for loop to check them) into a new DataTable and then, for each row in the DataTable, I've created an SQL...
29 Sep 2020 by Member 12885549
I generate lines of rows to insert: private StringReader MapWithHeaders(StreamReader reader, int clientId, HeadersMap dataHeadersMap, string delimiter, int uploadDataId, string dateFormat) { var lines = new...
12 Dec 2022 by Dave Kreskowiak
Simple really. The DataTable you created has no columns in it. It's completely empty and this is what you are trying to bulk copy to the SQL table. No columns means there are no column names for the ColumnMappings to match up to.
28 Dec 2022 by dhivyah jaiya
Window application for import csv data to sql server. Data from csv file can import , save in database . but how we can add if have all the column in database table but not have in one column in csvfile but still save other data column from...
28 Dec 2022 by OriginalGriff
You will have to add a column "Milliseconds" to the DataTable containing the CSV data, and provide it with a sensible default value.
19 May 2017 by Yuriy Magurdumov
Two flavors of IDataReader implementations used together with SqlBulkCopy to insert static and dynamic data structures into SQL Server table.
20 Feb 2015 by Veronica S. Zotali
How to BulkLoad a file with millions of records
17 Jun 2023 by OriginalGriff
Look at your code:objbulk.ColumnMappings.Add("Policy End Date", "Policy End Date"); Then chck the tables: policy_end_date should be in that one: objbulk.ColumnMappings.Add("Policy End Date", "policy_end_date");
8 Dec 2013 by Amogh Natu
Hi,I'm writing a method to import data from excel into a table in sql server. Excel sheet has columns "StudentID", "CourseID", "FirstName", "LastName", "StudentEmail", "StudentPassword". The table also has the exact same column names.I'm using the code given below. public void...
7 Oct 2013 by Vikash Kumar
SQL bulk copy with strongly typed data including validation.
10 Dec 2012 by sachin bankar
How to use the result set from a Stored Procedure in a Select statement.
27 Nov 2012 by Srinivasu Pemma
This is the best way to handle or manage bulk data insert to sql server taken from my technical blog http://www.srinetinfo.com/2012/11/bulk-data-management.html
23 Jun 2014 by _Asif_
One quick suggestion is to import all the records in a temporary table using SQLBulkCopy. Once all records gets imported then you execute a stored procedure who first import parent records and then import child records from temp table with updated reference keys with respect to the parent tables
7 Dec 2017 by Akshada Sane
For "Name"(Line No 20) In My Excel Sheet Data is Akshada,Shivani,Malvika,Rutu But I want to store in data table like this id Name 1 Akshada 2 Shivani 3 Malvika 4 Rutu // below code stores all same to same data from excel to database...
12 Dec 2022 by dhivyah jaiya
i try to import csv data into sql server using window application. but i get this error while import the data.Any suggestion to fix this error? What I have tried: private void btnImport_Click(object sender, EventArgs e) { ...
17 Jun 2023 by Akshay malvankar
Following is my datable column Policy No Certificate/Asset Number Policy Start Date Policy End Date Loan Account No Customer Name Hypothecation Risk Location Address Suminsured Action Following is my databse table column ...