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 |
|
SunnyDee
Yak Posting Veteran
79 Posts |
Posted - 2007-02-12 : 14:36:05
|
| Below is what the recordset should look like, with the second column value incrementing by 1 for every repeated value in column 1.4748 14748 24748 34748 4 4749 14749 24749 34749 44749 54750 14750 24750 34750 44750 5what is the best way to make sure future updates to this table follow this format? The original recordset is Excel and we are moving to SQL Server. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 14:38:53
|
| It depends on where the values come from, what to start with for first new value in new group.We need some more information.Peter LarssonHelsingborg, Sweden |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-02-12 : 15:54:29
|
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspxpoint 1Go with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-13 : 01:15:39
|
| [code]-- prepare sample datadeclare @t table (grp int, value int)insert @tselect 4748, 1 union allselect 4748, 2 union allselect 4749, 1 union allselect 4750, 1 union allselect 4750, 2 union allselect 4750, 3select grp, valuefrom @torder by grp, value-- show the new valuesselect x.grp, x.valuefrom ( select grp, max(value) + 1 as Value from @t group by grp union all select grp, value from @t ) as xorder by x.grp, x.value[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
SunnyDee
Yak Posting Veteran
79 Posts |
Posted - 2007-02-13 : 14:10:19
|
| Thank you. I was able to use your code and modify it slightly to fit my needs. |
 |
|
|
|
|
|
|
|