471,306 Members | 851 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

How can i insert thousand records using single query?

Suppose,
i hv an 10 columns and next to that other columns in a DB Table. That 10 columns hv same default values & others are retriving from other table and are nearly 1000 records. How can i insert that 1000 records using single query or by other method in DB Table ?
i used the forloop for 1000 records but it degrades the performance. i want a better solution on this.
Help me, Pls.
May 11 '07 #1
3 3188
pradeep kaltari
102 Expert 100+
Suppose,
i hv an 10 columns and next to that other columns in a DB Table. That 10 columns hv same default values & others are retriving from other table and are nearly 1000 records. How can i insert that 1000 records using single query or by other method in DB Table ?
i used the forloop for 1000 records but it degrades the performance. i want a better solution on this.
Help me, Pls.
Hi Tushar,
I guess you are looking for something like this:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO table1(col1,col2,...)
  2. SELECT col1,col2,...
  3. FROM table2
  4.  
If you are looking for something else then please let us know. Also, it would be better if you post you code so that it would give an idea as what you are looking for.

Regards,
Pradeep
May 11 '07 #2
debasisdas
8,127 Expert 4TB
Welcome to TSDN.

Hope u enjoy the forum.

Feel free to put your doubts/queries in the forum.

But first give a try from your side before posting in forum.

And if possible mention what/how u have tried to solve the problem .

Then it will be helpful for the Experts in the forum in understanding/solving your problem


Best of Luck..
May 11 '07 #3
debasisdas
8,127 Expert 4TB
It is not at all clear from your query what u want.

IF the structure of both the tables are same AND u want to insert data of one table to another thable THEN

Expand|Select|Wrap|Line Numbers
  1. insert into table1(select * from table2);
  2.  
But if your query is different please do post back.
May 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by os2 | last post: by
6 posts views Thread by rn5a | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.