insert

Why would bulk Inserts cause an ASP.net application to become Unresponsive?

Setup: ASP.net 3.5, Linq-to-Sql. Separate Web and DB servers (each 8-core, 8GB RAM). 4 databases. I am running an insert operation with a few million records into DB4 (using Linq-to-Sql for now, though I might switch to SqlBulkCopy). Logging shows that records are being put in consistently at a rate of 600-700 per second (I am running Da...

Which is faster: multiple single INSERTs or one multiple-row INSERT?

I am trying to optimize one part of my code that inserts data into MySQL. Should I chain INSERTs to make one huge multiple-row INSERT or are multiple separate INSERTs faster? ...

How to insert a image under the text as a pdf background using iText ?

I need some sample code to insert a image as a pdf background, is there any this kind of sample code ? and I have wrote the text well, then i need to insert a image under the text. ...

SQL: insert as 1 query with all fields, or multiple queries?

So I have a question regarding the best practice for a PHP page inserting a new row into a table. There are some required fields (aka NOT NULL) and some optional fields (can be NULL). Is it better to insert everything with one query, or just do the required fields, get the inserted ID and update the other fields with one or more other ...

Python MySQLdb: Update if exists, else insert

I am looking for a simple way to query an update or insert based on if the row exists in the first place. I am trying to use Python's MySQLdb right now. This is how I execute my query: self.cursor.execute("""UPDATE `inventory` SET `quantity` = `quantity`+{1} WHERE `item_number` = {0} ...

How to use variable in target database name for insert statement?

I want to declare a server name and use this name in an insert statement. So far all i got is an error message. declare @machine nvarchar(6); declare @bar nvarchar(3); set @machine = 'Name00'; set @bar = 'foo' insert into @machine.dbname.dbo.table (column1, column2) select (column1, column2) from table where column1 = @bar This gives...

Insert using linq templates not returning the id - MySQL

I'm using the latest subsonic dll and the latest linq templates from github. The db i'm inserting into is MySQL. Id column on table is primary key auto increment. Versions: Subsonic.Core.dll - 3.0.0.3 - (November 18, 2009 Merged pulls from Github). LinqTemplates - July 29, 2009. MySQL.Data.CF.dll - 6.1.2.0. The row is inserted but th...

Default values in Insert Select in SQL

How to pass default values in the Insert Select construction in SQL? I have a table: create table1 (field1 int, field2 int, field3 int default 1337) create table2 (field1 int, field2 int) I want to insert table2 into table1 with a construction similar to this: insert into table1 select field1, field2, DEFAULT from table2...

How to Insert Records based on the Previous Insert?

Here's my procedure: PROCEDURE add_values AS BEGIN INSERT INTO TABLE_A ... SELECT t.id, t.name FROM TABLE_C ("This selection will return multiple records") END While it inserts in TableA, I would like insert into another table(TableB) for that particular record which got inserted in tableA. The columns in TableA and TableB ar...

CTE vs multiple inserts

As we all know, CTEs were introduced in SQL Server 2005 and the crowd went wild. I have a case where I'm inserting a whole lot of static data into a table. What I want to know is which of the following is faster and what other factors I should be aware of. INSERT INTO MyTable (MyField) VALUES ('Hello') INSERT INTO MyTable (MyField) VAL...

Hibernate, insert or update without select.

I have a products objects which belongs to certain categories i.e. classical many to one relationship. @Entity public class Product{ @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id; String name; Double price; @ManyToOne(fetch = FetchType.LAZY) Category category; ... } @Entity public class Categ...

PHP / MySql Insert on GoDaddy

I'm using heredocs for a php/mysql insert statement on godaddy. When the function is called the page refreshes correctly, however, the data is not being inserted into the database and no errors are appearing. I've tested locally using MAMP and when the file is uploaded to the server it does not work. Has anyone had this issue before o...

INSERT INTO a table from another table, but with the correct user ID for each comment a user adds.

I have two tables - a 'users' and a 'comments'. They both have the coloum 'IDUsers'. When a user adds a comment I want their user ID to come from the 'users' table and go into the 'comments' table into the 'IDUsers' coloum from the 'IDUsers' coloum. However, at the same time a comment is being added from the user - so I also am using t...

failed to prepare insert statement

sqlite3 *insert_statement=nil; if (insert_statement == nil) { static char *query = "INSERT INTO iteminfo (itemname, friendid) VALUES(?,?) where itemid=?"; if (sqlite3_prepare_v2(database, query, -1, &insert_statement, NULL) != SQLITE_OK) { NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_e...

How to get the value of id(primary key) in previous operation in MySQL

I am using MySQL. I need to insert one row into a table first, then I need to get the id of the inserted row. The code looks somewhat like the following: insert into mytable (column2, column3, column4) values('value2','value3','value4')or die(mysql_error()); Column1 is the primary key and it is auto-increment. So how to ge...

not preparing insert query

if (insert_statement == nil) { static char *query = "INSERT INTO iteminfo (itemname, friendid) VALUES(?,?) where itemid=?"; if (sqlite3_prepare_v2(database, query, -1, &insert_statement, NULL) != SQLITE_OK) { NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database)); } i am new to Objective ...

inserting with linq

hi i am trying to insert a load of data into a table with linq the data arrives in a nameValueCollection with the key as the column name and the value as the value to be inserted i need to convert all the values to their correct datatype but cant think of a good way to do this and then insert i can iterate over the columns in the LINQ...

iterating over linq entity column

hi , i need to insert a record with linq i have a namevaluecollection with the data from a form post.. so started in the name=value&name2=value2 etc.. type format thing is i need to inset all these values into the table, but of course the table fields are typed, and i need to type up the data before inserting it i could of course exp...

SQL Insert trigger to update INSERTED table values

Hello. I want to create an Insert trigger that updates values on all the inserted rows if they're null, the new values should be taken from a different table, according to another column in the inserted table. I tried: UPDATE INSERTED SET TheColumnToBeUpdated = ( SELECT TheValueCol FROM AnotherTable.ValueCol WHERE Another...

inserting rows from one table to another, which sql is more efficient (outer join vs sequential scan)

I need to copy over rows from Table B to Table A. The requirement is to only insert rows that are not already in A. My question is, which is of the the following two is more efficient: A) INSERT INTO A (x, y, z) SELECT x, y, z FROM B b WHERE b.id NOT IN (SELECT id FROM A); B) INSERT INTO A (x, y, z) SELECT b.x, b....