| Author |
Topic |
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-09-18 : 06:38:02
|
| I need to insert 5 lakhs records in a table. I dont want to do it in a single go. Is there a way to insert it in ,say, 5 batches using a script. Any help will be much appreciated. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-18 : 06:44:06
|
| Depends on the way you are inserting data. Are you copying records from one table to another?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-09-18 : 07:20:06
|
| Yes, Harsh |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-18 : 08:15:53
|
If you are having an identity column, you could tryinsert table1select * from table2where table2.id % 5 = 0insert table1select * from table2where table2.id % 5 = 1insert table1select * from table2where table2.id % 5 = 2insert table1select * from table2where table2.id % 5 = 3insert table1select * from table2where table2.id % 5 = 4 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-09-18 : 08:23:39
|
| Peso, Thnaks for the reply, But unfortunately i dont have Identity keys in the Tables. Is there any other way to do this? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-18 : 08:30:20
|
[code]insert table1 ( {col list here} )select ( {col list here} ) from (select {col list here}, ntile(5) over (ORDER BY {somecol}) AS Grp from table2) AS d WHERE Grp = 1insert table1 ( {col list here} )select ( {col list here} ) from (select {col list here}, ntile(5) over (ORDER BY {somecol}) AS Grp from table2) AS d WHERE Grp = 2insert table1 ( {col list here} )select ( {col list here} ) from (select {col list here}, ntile(5) over (ORDER BY {somecol}) AS Grp from table2) AS d WHERE Grp = 3insert table1 ( {col list here} )select ( {col list here} ) from (select {col list here}, ntile(5) over (ORDER BY {somecol}) AS Grp from table2) AS d WHERE Grp = 4insert table1 ( {col list here} )select ( {col list here} ) from (select {col list here}, ntile(5) over (ORDER BY {somecol}) AS Grp from table2) AS d WHERE Grp = 5[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-09-28 : 08:35:15
|
| sorry for the late reply, it took some time for me to test this, peso, thanx very much!! that did the trick!! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-09-28 : 14:05:56
|
| http://en.wikipedia.org/wiki/LakhOne lakh is equal to a hundred thousand_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 14:14:32
|
| Is a lakh kin to a yak? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 14:19:35
|
| Yea, I was just trying to be funny...obviously I was unsucessful. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-09-28 : 14:42:42
|
if it helps... i laughed _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-10-11 : 10:42:29
|
| me too :) |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-10-11 : 10:42:50
|
| sorry for that usage too... |
 |
|
|
|