Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2003-01-29 : 03:00:16
|
I have a table called sales has 25000 records: DayCount sales1 1202 ::: 145Until 25000 148 I would like to insert 3000 more records after 25000 rows so the DayCount of new records start from 25001 ~~~ until 28000.what is the best way to do it? Using Cursor? I would appreciated if you can show me an example code |
|
|
rihardh
Constraint Violating Yak Guru
307 Posts |
Posted - 2003-01-29 : 03:16:44
|
| You could use a while loop...What datatype is "DayCount"? |
 |
|
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2003-01-29 : 03:52:18
|
| It's int.is there any good example? |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-01-29 : 07:36:21
|
| Just "copy" 3000 of your existing records and add 25000 to the DayCount field... Not sure what your "sales" field should be, this isn't making a lot of sense to me what you are trying to accomplish.INSERT INTO YourTableSELECT DayCount + 25000, (whatever you want for sales)FROMYourTableWHERE DayCount <=3000- Jeff |
 |
|
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2003-01-29 : 10:55:54
|
I just wanted to try a Cursor to accomplish this (as an experiment ) instead of using DML statement. For example, I have a sales table ( Daycount(int), sales ( money) ) which has 25000 records and am trying to insert 3000 more records ( let's called #sales) which has the exact same data format ( Daycount(int), sales ( money) ) after row number 25000. so it should be look like DayCount sales ------- ------ 1 120 2 : : 25000 145 25001 148 : : 28000 100 Is this make sense to you?;)Thank you for the help! |
 |
|
|
|
|
|