I have a table roughly like this:
ID RecNo
1 1
2 Null
3 Null
4 1
5 Null
6 2
7 Null
8 2
What I would like to do is change the table to:
ID RecNo
1 1
2 1
3 1
4 1
5 Null
6 2
7 2
8 2
i.e. fill in the blanks between similar numbers.
Can I do this with one good sql statement? Rather than a cursor or a loop as this would require thousands of separate updates.
I thought maybe using something vaguely along the line of the procedure in the faq could be used?
declare @variable int
set @variable = 0
update table
SET @variable = column = @variable + 1
ID RecNo
1 1
2 Null
3 Null
4 1
5 Null
6 2
7 Null
8 2
What I would like to do is change the table to:
ID RecNo
1 1
2 1
3 1
4 1
5 Null
6 2
7 2
8 2
i.e. fill in the blanks between similar numbers.
Can I do this with one good sql statement? Rather than a cursor or a loop as this would require thousands of separate updates.
I thought maybe using something vaguely along the line of the procedure in the faq could be used?
declare @variable int
set @variable = 0
update table
SET @variable = column = @variable + 1