insert

SQL Server 2008 BULK INSERT DateTime Error

I am trying to use BULK INSERT in SQL Server 2008 to import a TSV (Tab Separated Value) file. Here is my script: USE ABC GO CREATE TABLE CSVTest (ID INT, FirstName VARCHAR(40), LastName VARCHAR(40), TodaysDate DATETIME) GO BULK INSERT CSVTest FROM 'd:\csvtest.txt' WITH ( FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n' ) GO --Check the ...

how to cache latest inserted data in MySQL?

Is it possible to cache recently inserted data in MySQL database internally? I looked at query cache etc (http://dev.mysql.com/doc/refman/5.1/en/query-cache.html) but thats not what I am looking for. I know that 'SELECT' query will be cached. Details: I am inserting lots of data to MySQL DB every second. I have two kind of users for ...

INSERT statement fails silently in PHP-script, but works at the prompt

Hello, I have the following table in PostgreSQL 8.4.5: snake=> create table gps ( id bytea check(length(id) = 16), stamp timestamp DEFAULT current_timestamp, pos point not null); and I'm able to INSERT record into it from psql prompt: snake=> insert into gps (id, pos) values (decode(md5('x'), 'hex'), point(0, 0)); INSERT 0 1 snake=>...

How to insert data in PDo

I use PDO and i can't insert some data: use this code: $sql = 'INSERT INTO `releases` (id, artists, release, label, catalog, date, tracklist, type, status, vote, votes_count) '; $sql .= 'VALUES (:id, :artists, :release, :label, :catalog, :date, :tracklist, :type, :status, :vote, :votes_count)'; $query = $this->db->prepare($sql); $qu...

dynamic multiple insert

Hi I have a form that allows users to insert "items" in a database. A field asks how many items they want to insert. Identical data (apart from their ID) is inserted in the database the number of times they chose. I've found different ways to insert multiple items but not when this is dynamically done. I'm using .net 3.5 and SQLServer 2...

Handling error in multiple insert script (sql)

Hi all, I need to insert about 500 images to database at once. I have a script, that builds multiple query script: SELECT 'INSERT INTO [truvle].[dbo].[Ads_Images]([Img_adId],[Img_image]) SELECT CONVERT(INT, ' + CAST([Ad_id] AS VARCHAR) + ')' + ',(SELECT * FROM OPENROWSET(BULK N''' + [Ad_path] + ''', SINGLE_BLOB) as [somethin...

inserted writes

code : SqlConnection sqlc = new SqlConnection( "Data Source=" + Environment.MachineName + @"\SQLEXPRESS;" + "Integrated security=true;" + "database=someDB"); SqlCommand sqlcmd; string tmp = string.Empty; for(int i = 0; i < 100000; i++) { tmp += "inserto into [...

ibatis: improve insert performace

Hi I am using ibatis for my sql insert stmt. In my code i am parsing files line by line from a folder. Each line that matches criteria, need to be inserted into database. Total number of insert in a single run of program can be any where along 200k. SqlSession sess = null; this.sess = sf.openSession(ExecutorType.BATCH, fals...

STL Set: insert two million ordered numbers in the most efficient manner

For the following mass-insert, because the inputs are ordered, are there any (slight) optimizations? set<int> primes; for ( int i = 2; i <= 2000000; i++ ) { primes.insert(i); } // then follows Sieve of Eratosthenes algorithm New improvement, twice as fast: set<int> primes; for ( int i = 2; i <= 2000000; i++ ) { primes.inser...

SQL CASE statements on Informix - Can you set more than one field in the END section of a case block?

Using IBM Informix Dynamic Server Version 10.00.FC9 I'm looking to set multiple field values with one CASE block. Is this possible? Do I have to re-evaluate the same conditions for each field set? I was thinking of something along these lines: SELECT CASE WHEN p.id = 9238 THEN ('string',3) END (varchar_field, int_field); Where the...

ERROR: check the manual [...] MySQL server version for the right syntax to use near '

So I have no idea what the deal is here... the following code below produces the mysql error following the code. $fcontents = file("inventory.csv"); for ($i = 1; $i < sizeof($fcontents); $i++) { $line = trim($fcontents[$i]); $arr = explode(',', $line); $values = implode(',', $arr); $values = str_replace('&', 'and', $va...

Insert data from another DB in tables

Hi all, I'm having some issue here. Let me explain. So I was about done with migration of this project and I've decided to run the test suite to make sure the logic was still working as expected. Unfortunately, it didn't... but that's not the issue. At the end of the suite, there was a nice script that execute a delete on the datas of ...

SQL Server 2005: T-SQL INSERT INTO and OUTPUT timestamp to a variable

Example: IF OBJECT_ID('T1') IS NOT NULL DROP TABLE T1; GO CREATE TABLE T1 (id int PRIMARY KEY, timestamp); GO INSERT INTO T1(id) VALUES (1); GO declare @v timestamp; INSERT INTO T1(id) OUTPUT inserted.timestamp as v VALUES (10); select @v How can I get the inserted.timestamp into variable @v? ...

JDBC insert statement is not working

I am trying to insert new record, using jdbc. Everything look like ok, I don't have any exception, but new record isn't inserted into the table. Select statement works right. public Connection getConnection(){ Connection conn=null; try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { ...

Split multiple lines and input them in separate row in a database

Hi Guys, I am trying to create a php script that inputs the HTTP links pasted into a textarea into a separated row in a database. More exactly: First page is where the textarea (name=textarea-linkfield) is, links are going to be pasted here http://www.stackoverflow.com http://www.yahoo.com .... http://google.com The links are being ...

SQL Query Error

What is wrong with this Query? INSERT INTO Registration (`Status`, `String`) VALUES ('Confirmed', '0') WHERE `String` = '". mysql_real_escape_string($user) ."' 1A: UPDATE Registration `Status` = 'Confirmed', `String` = '0' WHERE `String` = '". mysql_real_escape_string($user) ."' ...

Problem changing Formview mode on GridView_SelectedIndexChanged

I want my Formview to start in Insert mode and then change to Edit mode when a user selects a row from the Gridview in the same page. The Formview has the inline attribute: DefaultMode="Insert" How can this be done and why isn't this working? protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e) { ...

MySQL FK syntax: insert column called practice into table cred_insurances that is FK to table practices

I need to insert a column called "practice" into table "cred_insurances" that is a FK referencing table "practices" PK "id" ...

linq to sql datacontext, inserting objects and retrieving the id and appending it to another table??

Wierd question title... What i am trying to accomplish is pretty simple i think. I got 3 tables in the database, BlogPost - BlogPostTagsConnection - Tags The blogpost contains text, title, slug, author, id etc. The BlogPostTagsConnection contains the BlogPost id and the Tags id and finally the Tags contains tagid and tag. So i tried...

Using Java to populate a specific column in an SQL table

Essentially, I have a methods that manipulates data taken from a table to create a new object "ZExpert." ZExpert has parameters int id, int domain, and double ZExpert. I have added a column to the table I took the data from called "Z_Expert_Score." I want to put the double ZExpert score from the object in the column Z_Expert_Score, in ...