views:

474

answers:

1

i am reading records data from a file(records count can be up to thousands ).Now i want to insert each record in to database.I want to insert all of records in one hit to reduce performance hit. If i use addBatch(String sqlQuery ) on statment object,my sql query should be static .but in my case query will be non static.Please tell me possible solutions with best performance?

platform java 1.4 sql server 2000.

+1  A: 

From Wiki

A SQL feature (since SQL-92) is the use of row value constructors to insert multiple rows at a time in a single SQL statement:

INSERT INTO ''TABLE'' (''column1'', [''column2, ... '']) 
VALUES (''value1a'', [''value1b, ...'']), 
       (''value2a'', [''value2b, ...'']), 
   ...
o.k.w
thanks.in this case,i will have to generate my sql query dynamically depending upon number of records.If there is some better solution,pls tell?
Maddy.Shik
its not working on sql server 2000.
Maddy.Shik
What error do you get? If I'm not wrong, MSSQL2000 should be SQL-92 compliant.
o.k.w