Hi I want to add/assign value to row which are null with previous row value in SQL Server 2005
Example:
Col1 Col2
1 45
NULL 30
2 20
3 40
NULL 30
NULL 20
4 40
Output must be like this
Col1 Col2
1 45
1 30
2 20
3 40
3 30
3 20
4 40
I Assume that you have a column named
idwhich is a primary key, or your default order is made by this field, and I assume that your table’s name is t1.here is the query which gives the result you need: