bulkinsert

Faster way to get an SQL-compatible string from a Guid

I noticed this particular line of code when I was profiling my application (which creates a boatload of database insertions by processing some raw data): myStringBuilder.AppendLine( string.Join( BULK_SEPARATOR, new string[]{myGuid.ToString() ... Bearing in mind that the resultant string is going to end up in a file called ...

SQL Server Bulk Insert Issue on Windows7

Hi, I’ve got an application that uses SQL Server Express 2005 SP3. This application is distributed to several hundred users, each of whom is running XP. However, our company will be moving to Windows7 soon. My application uses the bulk insert operation in SQL Server, and it runs fine in XP. However, in Windows7 I need to open SQL Ser...

Performing a INSERT INTO ... SELECT with LINQ to SQL

I'm trying to figure out if it's possible to perform an "insert into ... select" type command with LINQ to SQL. A bit of LINQ to SQL code that would allow me to send one single SQL command to the database that would insert multiple rows into a given table. For example, how to make LINQ to SQL send the following T-SQL statement to an SQ...

Batch Insert with Mysql Connector for .NET

I was wondering if there is any Bulk Insert functionality available on the MySql Connector. I do have to create millions of records and I believe the batching will be a great feature for this. I'm working on an MVC project with a MySql datastore. Thanks, Leonardo ...

How to BULK INSERT a file into a *temporary* table where the filename is a variable?

I have some code like this that I use to do a BULK INSERT of a data file into a table, where the data file and table name are variables: DECLARE @sql AS NVARCHAR(1000) SET @sql = 'BULK INSERT ' + @tableName + ' FROM ''' + @filename + ''' WITH (CODEPAGE=''ACP'', FIELDTERMINATOR=''|'')' EXEC (@sql) The works fine for standard tables, b...

What is the best way to perform a manipulation with huge amounts of data in SQL Server ?

We need to perform the following operation in our database : There is a table A which has column B_ID that is a foreign key to the table B. There are many rows in the table A that have the same value of B_ID and we want to fix this by cloning the corresponding rows in B and redirecting the rows from A to them. All this is relatively si...

SQL Server 2008 - Execute Batch Job and Bulk Insert in T-SQL

Hi I am faced with an interesting problem and I am not even sure if it is possible: I need to create a Stored Procedure in SQL Server 2008 that when executed does the following: Executes a Batch file - located on the SQL Server (i.e. C:\Mybatchfile.bat) - This Batch file will output a single text file to a directory on the SQL Server...

SQL Server 2008 - Bulk Insert a whole text file into one field

I have a text file (txt) containing formatted text (just line breaks, carriage returns and tabs) It also contains German language characters. I want to use the Bulk Insert comment in T-SQL to read in the text file into one field within a database table. I ran this command: CREATE TABLE #MyTestTable ( MyData NVARCHAR(MAX) ) BUL...

Bulk inserts into sqlite db on the iphone...

I'm inserting a batch of 100 records, each containing a dictonary containing arbitrarily long HTML strings, and by god, it's slow. On the iphone, the runloop is blocking for several seconds during this transaction. Is my only recourse to use another thread? I'm already using several for acquiring data from HTTP servers, and the sqlite do...

Passing Binary Data to a Stored Procedure in SQL Server 2008

I'm trying to figure out a way to store files in a database. I know it's recommended to store files on the file system rather than the database, but the job I'm working on would highly prefer using the database to store these images (files). There are also some constraints. I'm not an admin user, and I have to make stored procedures to ...

SQL Server insert performance

I have an insert query that gets generated like this INSERT INTO InvoiceDetail (LegacyId,InvoiceId,DetailTypeId,Fee,FeeTax,Investigatorid,SalespersonId,CreateDate,CreatedById,IsChargeBack,Expense,RepoAgentId,PayeeName,ExpensePaymentId,AdjustDetailId) VALUES(1,1,2,1500.0000,0.0000,163,1002,'11/30/2001 12:00:00 AM',1116,0,550.0000,850,NU...

Insert ADO.Net DataTable into an SQL table

The current solution i implemented is awful! I use a for... loop for inserting records from an ADO.NET data-table into an SQL table. I would like to insert at once the data-table into the SQL table, without iterating... Is that possible, or am i asking too much? ...

SQLite Bulk Import

I am sure there is no easy way to do this but I have ~400 excel files containing data. Each excel file contains the same headers. Is there an easy way of bulk inserting all 400 files at one time or in some form of batch process instead of doing in manually? Thanks. ...

Bulk Insert takes 4x as long on first operation of the day

I do Bulk Inserts into a table with about 14 million rows at fiver minute increments during a 7 hour period during the day. These inserts take somewhere between 9-14 secs. However, the first insert always takes about 40 secs. Anyone know what SQL Server 2005 would be doing differently on the first insert into a table for that day? Fr...

How to bulk insert from CSV when some fields have new line character?

I have a CSV dump from another DB that looks like this (id, name, notes): 1001,John Smith,15 Main Street 1002,Jane Smith,"2010 Rockliffe Dr. Pleasantville, IL USA" 1003,Bill Karr,2820 West Ave. The last field may contain carriage returns and commas, in which case it is surrounded by double quotes. And I need to preserve...

bulk insert image from relative path

Hi, I wonder if some can help me out with this little problem. I have the following insert statement: insert into symbol (sy_id, sy_fg_color, sy_bg_color, sy_icon) select 302, 0, 16245177, sy_icon = (select * from openrowset(bulk 'K:\mypath\icons\myicon.png', single_blob) as image) Is it possible to make the path relative in any way? ...

MySql BulkCopy/Insert from DataReader

I am loading a bunch of rows into MySql in C#. In MS Sql I can feed a DataReader to SqlBulkCopy, but the MySqlBulkCopy only presents itself as a bootstrap for a bulk load from file. So, my current solution is using a prepared command in a transacted loop. Is there a faster way to accomplish bulk loading of MySql using a DataReader sour...

bulk insert and update with ADO.NET Entity Framework

I am writing a small application that does a lot of feed processing. I want to use LINQ EF for this as speed is not an issue, it is a single user app and, in the end, will only be used once a month. My questions revolves around the best way to do bulk inserts using LINQ EF. After parsing the incoming data stream I end up with a List o...

Bulk Copy from one server to another

I've one situation where I need to copy part of the data from one server to another. The table schema are exactly same. I need to move partial data from the source, which may or may not be available in the destination table. The solution I'm thinking is, use bcp to export data to a text(or .dat) file and then take that file to the destin...

In TSQL (SQL Server), How do I insert multiple rows WITHOUT repeating the "INSERT INTO dbo.Blah" part of the statement?

I know I've done this before years ago, but I can't remember the syntax, and I can't find it anywhere due to pulling up tons of help docs and articles about "bulk imports". Here's what I want to do, but the syntax is not exactly right... please, someone who has done this before, help me out :) INSERT INTO dbo.MyTable (ID, Name) VALUES ...