I'm using sql Server 2008.
following dataPool:
PK Col1 Col2
1 SomeValue1 DataToTake1
2 SomeValue1
3 SomeValue1
4 SomeValue1
5 SomeValue2 DataToTake2
6 SomeValue2
...
i want to insert DataToTake1
into Col2
of records with PK
2, 3 and 4 and DataToTake2
into Col2
of record with PK
6.
to make it more obvious: records with PK
1-4 are groups, indicated by Col1
another info: PK
might not be incremental nor sequenced on productive system (but as we can group by Col1
, i hope that might not be a problem).
is there any way to to this with sql Server? (a companion implemented this with a pointer ... arggggh)
edit
thank you for your answers, but i have to revise my request, as my initial situation changed: i need to take PK in account. eg.
PK Col1 Col2
1 SomeValue1 DataToTake1
2 SomeValue1
4 SomeValue1
5 SomeValue2 DataToTake2
6 SomeValue2
9 SomeValue1
how to only update sequenced rows? with this example, PK 1 = 2 = 4