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 |
|
Dilan13
Starting Member
6 Posts |
Posted - 2010-12-13 : 11:33:12
|
| I currently have about 320 rows in a staging table , and I am buidling a parent child table from it. What I need to do is to group the rows into different parents. The destination table will have 2 columns ( parent , child) and I want to group the records to a max of 90 rows. For example the first 90 rows will be inserted as ,Parent1 rec1---Parent1 rec90and then the next 90 Parent2 rec91---Parent2 ---rec180the number of records in the source table will change so I need to dynamically identify the number of records, and assign them into parent with a max of 90 rows.I was thinking of using Cursor, but would like some suggestions on what would be the best way to do it..Thanks. |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2010-12-13 : 11:58:44
|
| I would suggest taking a look at the row number() function. This should give you some good ideas. Sorry I don't have time at the moment to provide an example but there are several examples on google.r&r |
 |
|
|
Dilan13
Starting Member
6 Posts |
Posted - 2010-12-13 : 15:33:39
|
| thanks. the ROw_number function is a pretty good option, and I am planning to use it |
 |
|
|
|
|
|