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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Insert cursor

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	                  sales
1 120
2 :
:
: 145
Until 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"?

Go to Top of Page

jung1975
Aged Yak Warrior

503 Posts

Posted - 2003-01-29 : 03:52:18
It's int.

is there any good example?

Go to Top of Page

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 YourTable
SELECT DayCount + 25000, (whatever you want for sales)
FROM
YourTable
WHERE DayCount <=3000

- Jeff
Go to Top of Page

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!

Go to Top of Page
   

- Advertisement -